@@ -711,6 +711,88 @@ protected class EntityWithIncludedComplexAddress
711711 public required string Street { get ; set ; }
712712 }
713713
714+ [ Theory ]
715+ [ InlineData ( "IsUnique" ) ]
716+ [ InlineData ( "IsDescending" ) ]
717+ [ InlineData ( "Filter" ) ]
718+ [ InlineData ( "IsClustered" ) ]
719+ [ InlineData ( "IncludeProperties" ) ]
720+ [ InlineData ( "IsCreatedOnline" ) ]
721+ [ InlineData ( "SortInTempDb" ) ]
722+ [ InlineData ( "DataCompression" ) ]
723+ public void Json_index_with_unsupported_option_throws ( string option )
724+ {
725+ var modelBuilder = CreateConventionModelBuilder ( ) ;
726+ modelBuilder . Entity < EntityWithIncludedComplexJson > ( b =>
727+ {
728+ b . ComplexProperty ( e => e . Address , cb => cb . ToJson ( ) ) ;
729+ var indexBuilder = b . HasIndex ( "Address.City" ) ;
730+
731+ switch ( option )
732+ {
733+ case "IsUnique" :
734+ indexBuilder . IsUnique ( ) ;
735+ break ;
736+ case "IsDescending" :
737+ indexBuilder . IsDescending ( ) ;
738+ break ;
739+ case "Filter" :
740+ indexBuilder . HasFilter ( "[Id] > 0" ) ;
741+ break ;
742+ case "IsClustered" :
743+ indexBuilder . IsClustered ( ) ;
744+ break ;
745+ case "IncludeProperties" :
746+ indexBuilder . IncludeProperties ( "Id" ) ;
747+ break ;
748+ case "IsCreatedOnline" :
749+ indexBuilder . IsCreatedOnline ( ) ;
750+ break ;
751+ case "SortInTempDb" :
752+ indexBuilder . SortInTempDb ( ) ;
753+ break ;
754+ case "DataCompression" :
755+ indexBuilder . Metadata . SetDataCompression ( DataCompressionType . Page ) ;
756+ break ;
757+ default :
758+ throw new InvalidOperationException ( ) ;
759+ }
760+ } ) ;
761+
762+ VerifyError (
763+ SqlServerStrings . JsonIndexUnsupportedOption (
764+ "{'City'}" , nameof ( EntityWithIncludedComplexJson ) , option ) ,
765+ modelBuilder ) ;
766+ }
767+
768+ [ Theory ]
769+ [ InlineData ( "FillFactor" ) ]
770+ [ InlineData ( "NonClustered" ) ]
771+ [ InlineData ( "NoIncludeProperties" ) ]
772+ [ InlineData ( "CreatedOffline" ) ]
773+ [ InlineData ( "SortInTempDbDisabled" ) ]
774+ public void Json_index_with_supported_option_passes ( string option )
775+ {
776+ var modelBuilder = CreateConventionModelBuilder ( ) ;
777+ modelBuilder . Entity < EntityWithIncludedComplexJson > ( b =>
778+ {
779+ b . ComplexProperty ( e => e . Address , cb => cb . ToJson ( ) ) ;
780+ var indexBuilder = b . HasIndex ( "Address.City" ) ;
781+
782+ _ = option switch
783+ {
784+ "FillFactor" => indexBuilder . HasFillFactor ( 80 ) ,
785+ "NonClustered" => indexBuilder . IsClustered ( false ) ,
786+ "NoIncludeProperties" => indexBuilder . IncludeProperties ( ) ,
787+ "CreatedOffline" => indexBuilder . IsCreatedOnline ( false ) ,
788+ "SortInTempDbDisabled" => indexBuilder . SortInTempDb ( false ) ,
789+ _ => throw new InvalidOperationException ( )
790+ } ;
791+ } ) ;
792+
793+ Validate ( modelBuilder ) ;
794+ }
795+
714796 [ Fact ]
715797 public virtual void Detects_incompatible_memory_optimized_shared_table ( )
716798 {
0 commit comments