This commit is contained in:
2020-12-24 18:19:23 +00:00
parent 068d8099cc
commit d9768d7a41

View File

@@ -91,7 +91,6 @@ namespace AyaNova.Models
foreach (var entity in modelBuilder.Model.GetEntityTypes())
{
// Replace table names
//entity.Relational().TableName = "a" + entity.Relational().TableName.ToLowerInvariant();
entity.SetTableName("a" + entity.GetTableName().ToLowerInvariant());
// Replace column names
@@ -103,8 +102,6 @@ namespace AyaNova.Models
{
property.SetColumnName("xmin");
property.SetColumnType("xid");
// property.Relational().ColumnName = "xmin";
// property.Relational().ColumnType = "xid";
property.ValueGenerated = ValueGenerated.OnAddOrUpdate;
property.IsConcurrencyToken = true;
}
@@ -113,24 +110,14 @@ namespace AyaNova.Models
}
foreach (var key in entity.GetKeys())
{
key.SetName(key.GetName().ToLowerInvariant());
// key.Relational().Name = key.Relational().Name.ToLowerInvariant();
}
foreach (var key in entity.GetForeignKeys())
{
//key.Relational().Name = key.Relational().Name.ToLowerInvariant();
key.SetConstraintName(key.GetConstraintName().ToLowerInvariant());
}
foreach (var index in entity.GetIndexes())
{
//index.SetName(index.GetName().ToLowerInvariant());
index.SetDatabaseName(index.GetDatabaseName().ToLowerInvariant());
}
}
///////////////////////////////
@@ -140,35 +127,8 @@ namespace AyaNova.Models
modelBuilder.Entity<WorkOrder>().Property(z => z.Serial).UseIdentityByDefaultColumn();
modelBuilder.Entity<Quote>().Property(z => z.Serial).UseIdentityByDefaultColumn();
modelBuilder.Entity<PM>().Property(z => z.Serial).UseIdentityByDefaultColumn();
//modelBuilder.Entity<PurchaseOrder>().Property(z => z.Serial).UseIdentityByDefaultColumn();
//modelBuilder.Entity<MetricCPU>().HasNoKey();
///////////////////////////////////////////////////////////////////////
//TODO: this entire block is almost certainly wrong or not required
// //Indexes must be specified through fluent api unfortunately
// modelBuilder.Entity<FileAttachment>().HasIndex(z => z.StoredFileName);
// //Relationships
// modelBuilder.Entity<Translation>()
// .HasMany(z => z.TranslationItems)
// .WithOne(z => z.Translation)
// .IsRequired();//default delete behaviour is cascade when set to isrequired
// modelBuilder.Entity<User>()
// .HasOne(z => z.UserOptions)
// .WithOne(z => z.User)
// .HasForeignKey<UserOptions>(z => z.UserId)
// .OnDelete(DeleteBehavior.Cascade);//Hopefully will delete the useroptions with the user?
// //User->Widget Not certain about this definition
// modelBuilder.Entity<User>()
// .HasOne(z => z.Widget)
// .WithOne(z => z.User)
// .HasForeignKey<Widget>(z => z.UserId)
// .OnDelete(DeleteBehavior.NoAction);
//////////////////////////////////////////////////////////////