コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
ファイル: ModelHelpers.cs プロジェクト: Dabbel/NETProvider
 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;
         }
     }
 }