public static void SetPrimaryKeyGeneration(ModelBuilder modelBuilder, FbValueGenerationStrategy valueGenerationStrategy = FbValueGenerationStrategy.SequenceTrigger) { foreach (var entityType in modelBuilder.Model.GetEntityTypes()) { var pk = entityType.FindPrimaryKey(); if (pk == null) { continue; } var properties = pk.Properties; if (properties.Count() != 1) { continue; } var property = properties[0]; if (property.GetValueGenerationStrategy() == FbValueGenerationStrategy.None) { property.SetValueGenerationStrategy(valueGenerationStrategy); } } }
public static void SetPrimaryKeyGeneration(ModelBuilder modelBuilder, DbContext context, FbValueGenerationStrategy valueGenerationStrategy = FbValueGenerationStrategy.SequenceTrigger) { foreach (var entityType in modelBuilder.Model.GetEntityTypes()) { var pk = entityType.FindPrimaryKey(); if (pk == null) { continue; } var properties = pk.Properties; if (properties.Count() != 1) { continue; } var fbPropertyAnnotations = properties[0].Firebird(); if (fbPropertyAnnotations.ValueGenerationStrategy == null) { properties[0].Firebird().ValueGenerationStrategy = valueGenerationStrategy; } } }