@@ -314,16 +314,18 @@ public static JetValueGenerationStrategy GetValueGenerationStrategy(this IReadOn
314314 return ( JetValueGenerationStrategy ? ) annotation . Value ?? JetValueGenerationStrategy . None ;
315315 }
316316
317+ var defaultValueGenerationStrategy = GetDefaultValueGenerationStrategy ( property ) ;
318+
317319 if ( property . ValueGenerated != ValueGenerated . OnAdd
318320 || property . IsForeignKey ( )
319321 || property . TryGetDefaultValue ( out _ )
320- || property . GetDefaultValueSql ( ) != null
322+ || ( defaultValueGenerationStrategy != JetValueGenerationStrategy . Sequence && property . GetDefaultValueSql ( ) != null )
321323 || property . GetComputedColumnSql ( ) != null )
322324 {
323325 return JetValueGenerationStrategy . None ;
324326 }
325327
326- return GetDefaultValueGenerationStrategy ( property ) ;
328+ return defaultValueGenerationStrategy ;
327329 }
328330 /// <summary>
329331 /// <para>
@@ -364,16 +366,15 @@ internal static JetValueGenerationStrategy GetValueGenerationStrategy(
364366 if ( sharedTableRootProperty != null )
365367 {
366368 return sharedTableRootProperty . GetValueGenerationStrategy ( storeObject , typeMappingSource )
367- == JetValueGenerationStrategy . IdentityColumn
368- && table . StoreObjectType == StoreObjectType . Table
369- && ! property . GetContainingForeignKeys ( ) . Any (
370- fk =>
371- ! fk . IsBaseLinking ( )
372- || ( StoreObjectIdentifier . Create ( fk . PrincipalEntityType , StoreObjectType . Table )
373- is StoreObjectIdentifier principal
374- && fk . GetConstraintName ( table , principal ) != null ) )
375- ? JetValueGenerationStrategy . IdentityColumn
376- : JetValueGenerationStrategy . None ;
369+ == JetValueGenerationStrategy . IdentityColumn
370+ && table . StoreObjectType == StoreObjectType . Table
371+ && ! property . GetContainingForeignKeys ( ) . Any ( fk =>
372+ ! fk . IsBaseLinking ( )
373+ || ( StoreObjectIdentifier . Create ( fk . PrincipalEntityType , StoreObjectType . Table )
374+ is { } principal
375+ && fk . GetConstraintName ( table , principal ) != null ) )
376+ ? JetValueGenerationStrategy . IdentityColumn
377+ : JetValueGenerationStrategy . None ;
377378 }
378379
379380 if ( property . ValueGenerated != ValueGenerated . OnAdd
@@ -382,12 +383,11 @@ is StoreObjectIdentifier principal
382383 || property . GetDefaultValueSql ( storeObject ) != null
383384 || property . GetComputedColumnSql ( storeObject ) != null
384385 || property . GetContainingForeignKeys ( )
385- . Any (
386- fk =>
387- ! fk . IsBaseLinking ( )
388- || ( StoreObjectIdentifier . Create ( fk . PrincipalEntityType , StoreObjectType . Table )
389- is StoreObjectIdentifier principal
390- && fk . GetConstraintName ( table , principal ) != null ) ) )
386+ . Any ( fk =>
387+ ! fk . IsBaseLinking ( )
388+ || ( StoreObjectIdentifier . Create ( fk . PrincipalEntityType , StoreObjectType . Table )
389+ is { } principal
390+ && fk . GetConstraintName ( table , principal ) != null ) ) )
391391 {
392392 return JetValueGenerationStrategy . None ;
393393 }
@@ -414,6 +414,19 @@ private static JetValueGenerationStrategy GetDefaultValueGenerationStrategy(IRea
414414 : JetValueGenerationStrategy . None ;
415415 }
416416
417+ /// <summary>
418+ /// Returns the <see cref="JetValueGenerationStrategy" /> to use for the property.
419+ /// </summary>
420+ /// <remarks>
421+ /// If no strategy is set for the property, then the strategy to use will be taken from the <see cref="IModel" />.
422+ /// </remarks>
423+ /// <param name="overrides">The property overrides.</param>
424+ /// <returns>The strategy, or <see cref="JetValueGenerationStrategy.None" /> if none was set.</returns>
425+ public static JetValueGenerationStrategy ? GetValueGenerationStrategy (
426+ this IReadOnlyRelationalPropertyOverrides overrides )
427+ => ( JetValueGenerationStrategy ? ) overrides . FindAnnotation ( JetAnnotationNames . ValueGenerationStrategy )
428+ ? . Value ;
429+
417430 private static JetValueGenerationStrategy GetDefaultValueGenerationStrategy (
418431 IReadOnlyProperty property ,
419432 in StoreObjectIdentifier storeObject ,
@@ -426,7 +439,7 @@ private static JetValueGenerationStrategy GetDefaultValueGenerationStrategy(
426439 ? property . DeclaringType . GetMappingStrategy ( ) == RelationalAnnotationNames . TpcMappingStrategy
427440 ? JetValueGenerationStrategy . None
428441 : JetValueGenerationStrategy . IdentityColumn
429- : JetValueGenerationStrategy . None ;
442+ : JetValueGenerationStrategy . None ;
430443 }
431444
432445 /// <summary>
@@ -522,12 +535,12 @@ public static void SetValueGenerationStrategy(
522535 public static bool IsCompatibleWithValueGeneration ( IReadOnlyProperty property )
523536 {
524537 var valueConverter = property . GetValueConverter ( )
525- ?? property . FindTypeMapping ( ) ? . Converter ;
538+ ?? property . FindTypeMapping ( ) ? . Converter ;
526539
527540 var type = ( valueConverter ? . ProviderClrType ?? property . ClrType ) . UnwrapNullableType ( ) ;
528541 return type . IsInteger ( )
529- || type . IsEnum
530- || type == typeof ( decimal ) ;
542+ || type . IsEnum
543+ || type == typeof ( decimal ) ;
531544 }
532545
533546 private static bool IsCompatibleWithValueGeneration (
0 commit comments