diff --git a/Gremlin/GremlinData/DBClasses/DbHelper.cs b/Gremlin/GremlinData/DBClasses/DbHelper.cs index 2cc671c..68619ad 100644 --- a/Gremlin/GremlinData/DBClasses/DbHelper.cs +++ b/Gremlin/GremlinData/DBClasses/DbHelper.cs @@ -79,8 +79,6 @@ namespace Gremlin.GremlinData.DBClasses /// Initialzes the Db with enum data: product lines, account types, submarkets { - DateTime now = DateTime.Now; - //PRODUCT LINES string[] ProductLineAbbrviations = { "XF", "LM", "XA", "RB", "GE", "9Z", "9P", "9M", "9K", "9H", @@ -1051,6 +1049,8 @@ namespace Gremlin.GremlinData.DBClasses { // Read current line fields, pointer moves to the next line. string[] fields = csvParser.ReadFields(); + //string productNumber = fields[0]; + //string? optionNumber = fields[1] == "" ? null : fields[1]; CustomDescription ImportedCD = new() { ProductNumber = fields[0], @@ -1060,7 +1060,7 @@ namespace Gremlin.GremlinData.DBClasses CoverletterText = fields[5], Notes = fields[6], }; - ImportedCD.Product = new(); + ImportedCD.Products = new List(); ImportedCD.Supplier = new(); ImportedCD.Supplier.AccountName = fields[2] is "" or "RB" ? "Agilent Technologies" : fields[2]; MetaDataSetter.ForImport(ImportedCD, "Importer", "Initial Importer by CD-ImporterFomCsv"); @@ -1117,12 +1117,12 @@ namespace Gremlin.GremlinData.DBClasses foreach (CustomDescription CD in CDsReadFromFile) { //Skip Desciptions, if it has been already imported above (as part from 3PP) - if (thirdPartyProductsFromImportedCDs.Contains(CD.Product)) continue; + if (thirdPartyProductsFromImportedCDs.Intersect(CD.Products).Any()) continue; //Establish EF Reference. If no PN/Opt found, then skip this custom description. //CD.Product = GetProduct(db, CD.ProductNumber, CD.OptionNumber); //ResolveXY-functions return null, if no match is found in db. - CD.Product = productsInDb.Find(p => p.ProductNumber == CD.ProductNumber && p.OptionNumber == CD.OptionNumber); - if (CD.Product == null) + CD.Products = productsInDb.Where(product => product.ProductNumber == CD.ProductNumber && product.OptionNumber == CD.OptionNumber).ToList(); + if (CD.Products == null) { CDsWithoutEFReferences.Add(CD); continue; @@ -1206,7 +1206,7 @@ namespace Gremlin.GremlinData.DBClasses importedCD.CoverletterText = stringsRead.ElementAt(5); importedCDs.Add(importedCD); - if (importedCDs.Count >= 1200 && importedCDs.Count % 100 == 0) MessageBox.Show(importedCDs.Count.ToString()); //DEBUGGING + //if (importedCDs.Count >= 1200 && importedCDs.Count % 100 == 0) MessageBox.Show(importedCDs.Count.ToString()); //DEBUGGING } } @@ -1260,11 +1260,12 @@ namespace Gremlin.GremlinData.DBClasses foreach (CustomDescription CD in importedCDs) { //Skip Desciptions, if it has been already imported above (as part from 3PP) - if (thirdPartyProductsFromImportedCDs.Contains(CD.Product)) continue; + if (thirdPartyProductsFromImportedCDs.Intersect(CD.Products).Any()) continue; //Establish EF Reference. If no PN/Opt found, then skip this custom description. - CD.Product = ResolveProduct(db, CD.ProductNumber, CD.OptionNumber); //ResolveXY-functions return null, if no match is found in db. - if (CD.Product == null) + CD.Products.Add(ResolveProduct(db, CD.ProductNumber, CD.OptionNumber)); //ResolveXY-functions return null, if no match is found in db. + + if (CD.Products == null) { CDsWithoutEFReferences.Add(CD); continue; diff --git a/Gremlin/GremlinData/DBClasses/EntityConfiguration.cs b/Gremlin/GremlinData/DBClasses/EntityConfiguration.cs index 1bf2561..8feb323 100644 --- a/Gremlin/GremlinData/DBClasses/EntityConfiguration.cs +++ b/Gremlin/GremlinData/DBClasses/EntityConfiguration.cs @@ -11,119 +11,38 @@ namespace Gremlin.GremlinData.DBClasses { entity.HasKey(e => e.AccountId); entity.HasMany(d => d.Contacts).WithOne(p => p.Account).IsRequired(true); - entity.HasOne(d => d.AccountType).WithMany(p => p.Accounts).IsRequired(true); - entity.HasOne(d => d.SubMarket).WithMany(p => p.Accounts).IsRequired(true); + entity.HasOne(d => d.AccountType).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict); + entity.HasOne(d => d.SubMarket).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict); entity.HasAlternateKey(e => e.SAPAccountNumber); // =Unique - entity.Property(e => e.AccountId) - .ValueGeneratedOnAdd() - ; + + entity.Property(e => e.AccountId).ValueGeneratedOnAdd(); entity.Property(e => e.ParentAccountId); - entity.Property(e => e.DataCreationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataValidFrom) - .HasColumnType("DATETIME") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataValidUntil) - .HasColumnType("DATETIME") - .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataVersionNumber) - .HasDefaultValue(1) - .IsRequired(true) - ; - entity.Property(e => e.DataVersionComment) - .HasDefaultValue("") - ; - entity.Property(e => e.DataStatus) - //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - .IsRequired(true) - ; - entity.Property(e => e.DataModificationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.DataModificationByUser) - .HasColumnType("TINYTEXT") - .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - ; - entity.Property(e => e.AccountName) - .IsRequired(true) - //.HasColumnType("VARCHAR(250)") - .HasMaxLength(250) //impliziert (mit diesem Wert?) VARCHAR - ; + entity.Property(e => e.AccountName).IsRequired(true).HasMaxLength(250); + //.HasColumnType("VARCHAR(250)") ist überflüssig, da .HasMaxLength(250) VARCHAR(250) impliziert. entity.Property(e => e.Notes); - entity.Property(e => e.Street) - .IsRequired(true) - .HasMaxLength(100) //impliziert (mit diesem Wert?) VARCHAR - ; - //entity.Property(e => e.Streetnumber) - // .IsRequired(true) - // .HasMaxLength(20) - // ; - entity.Property(e => e.ZIP) - .IsRequired(true) - .HasColumnType("Char(5)") - //.HasMaxLength(5) //impliziert (mit diesem Wert?) VARCHAR - ; - entity.Property(e => e.City) - .IsRequired(true) - .HasMaxLength(50) - ; - entity.Property(e => e.FloorOrBuilding) - //.HasColumnType("VARCHAR(50)") - .HasMaxLength(50) //impliziert (mit diesem Wert?) VARCHAR - ; - entity.Property(e => e.Longitude) - // .HasDefaultValue(null) - ; - entity.Property(e => e.Latitude) - // .HasDefaultValue(null) - ; - entity.Property(e => e.PhoneNumber) - .IsRequired(true) - .HasMaxLength(30) - ; - entity.Property(e => e.FaxNumber) - .HasMaxLength(30) - ; - entity.Property(e => e.Webpage) - //.HasColumnType("VARCHAR(250)") - .HasMaxLength(250) //impliziert (mit diesem Wert?) VARCHAR - ; - entity.Property(e => e.EMail) - //.IsRequired(true) - .HasMaxLength(150) //impliziert (mit diesem Wert?) VARCHAR - ; - //entity.Property(e => e.DateOfCreationInSAP); - //entity.Property(e => e.SubMarketCode); - //entity.Property(e => e.SubMarket); - //entity.Property(e => e.AccountType) - // .IsRequired(true) - // .HasColumnType("Char(3)") - // ; - //entity.Property(e => e.SubMarket) - // .IsRequired(true) - // .HasColumnType("Char(3)") - // ; - //entity.Property(e => e.LinkToSAP) - // .HasColumnType("Text"); - // --> in DbHelper mit eigener Funktion aus den SAP-Ids konstruieren. - entity.Property(e => e.SAPAccountNumber) - .IsRequired(true) - ; - entity.Property(e => e.AccountCreatedInSAPOn) - .IsRequired(true) - ; - - + entity.Property(e => e.Street).IsRequired(true).HasMaxLength(100); + entity.Property(e => e.ZIP).IsRequired(true).HasColumnType("Char(5)"); + entity.Property(e => e.City).IsRequired(true).HasMaxLength(50); + entity.Property(e => e.FloorOrBuilding).HasMaxLength(50); + entity.Property(e => e.Longitude); + entity.Property(e => e.Latitude); + entity.Property(e => e.PhoneNumber).IsRequired(true).HasMaxLength(30); + entity.Property(e => e.FaxNumber).HasMaxLength(30); + entity.Property(e => e.Webpage).HasMaxLength(250); + entity.Property(e => e.EMail).HasMaxLength(150); + entity.Property(e => e.SAPAccountNumber).IsRequired(true); + entity.Property(e => e.AccountCreatedInSAPOn).IsRequired(true); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -132,176 +51,68 @@ namespace Gremlin.GremlinData.DBClasses public void Configure(EntityTypeBuilder entity) { entity.HasKey(e => e.ContactId); - //entity.HasMany(d => d.CommunicationChannels).WithOne(p => p.Contact).IsRequired(true); entity.HasOne(p => p.Account).WithMany(d => d.Contacts).IsRequired(true); //entity.HasAlternateKey(e => e.SAPContactNumber); + entity.Property(e => e.ContactId); - entity.Property(e => e.DataCreationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.DataValidFrom) - .HasColumnType("DATETIME") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationByUser) - .HasColumnType("TINYTEXT") - .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - ; - entity.Property(e => e.DataValidUntil) - .HasColumnType("DATETIME") - .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataVersionNumber) - .HasDefaultValue(1) - .IsRequired(true) - ; - entity.Property(e => e.DataVersionComment) - .HasDefaultValue("") - ; - entity.Property(e => e.DataStatus) - //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - .IsRequired(true) - ; - entity.Property(e => e.SAPContactNumber) - .IsRequired(true) - ; + entity.Property(e => e.SAPContactNumber).IsRequired(true); entity.Property(e => e.AcademicTitle); entity.Property(e => e.FirstName); - entity.Property(e => e.LastName) - .IsRequired(true) - ; - entity.Property(e => e.Gender) - //.IsRequired(true) //darf nicht gesetzt werden, da sonst vom DB-Engine NULL nicht erlaubt wird (trotz Definition als Bool? im Code. MySQL kennt kein Bool, sondern wandelt das intern in Tinyint um). - ; - entity.Property(e => e.OptInStatus) - .HasDefaultValue(null) - ; - entity.Property(e => e.IsReference) - .HasDefaultValue(false) - ; + entity.Property(e => e.LastName).IsRequired(true); + entity.Property(e => e.Gender); + //.IsRequired(true) darf nicht gesetzt werden, da sonst vom DB-Engine NULL nicht erlaubt wird (trotz Definition als Bool? im Code. MySQL kennt kein Bool, sondern wandelt das intern in Tinyint um). + entity.Property(e => e.OptInStatus).HasDefaultValue(null); + entity.Property(e => e.IsReference).HasDefaultValue(false); entity.Property(e => e.Notes); - entity.Property(e => e.LinkToSAP); - entity.Property(e => e.ValidatedContact) - .HasDefaultValue(false) - ; + entity.Property(e => e.ValidatedContact).HasDefaultValue(false); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } - //public class CommunicationChannelConfiguration : IEntityTypeConfiguration - //{ - // public void Configure(EntityTypeBuilder entity) - // { - // entity.HasKey("CommunicationChannelId"); - // entity.HasOne(p => p.Contact).WithMany(e => e.CommunicationChannels).HasForeignKey("ContactId").IsRequired(true); - - // entity.Property(e => e.DataCreationDate) - // .HasColumnType("TIMESTAMP") - // .HasDefaultValueSql("CURRENT_TIMESTAMP") - // .ValueGeneratedOnAdd() - // ; - // entity.Property(e => e.DataModificationDate) - // .HasColumnType("TIMESTAMP") - // .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - // .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - // .IsConcurrencyToken(true) - // ; - // entity.Property(e => e.DataValidFrom) - // .HasColumnType("DATETIME") - // .HasDefaultValueSql("CURRENT_TIMESTAMP") - // .ValueGeneratedOnAdd() - // ; - // entity.Property(e => e.DataModificationByUser) - // .HasColumnType("TINYTEXT") - // .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - // ; - // entity.Property(e => e.DataValidUntil) - // .HasColumnType("DATETIME") - // .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - // .ValueGeneratedOnAdd() - // ; - // entity.Property(e => e.DataVersionNumber) - // .HasDefaultValue(1) - // .IsRequired(true) - // ; - // entity.Property(e => e.DataVersionComment) - // .HasDefaultValue("") - // ; - // entity.Property(e => e.DataStatus) - // //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - // .IsRequired(true) - // ; - - // entity.Property(e => e.Typ) - // .IsRequired() - // .HasMaxLength(50) - // ; - // entity.Property(e => e.Number) - // .IsRequired() - // .HasMaxLength(250) - // ; - // entity.Property(e => e.IsPreferred) - // .HasDefaultValue(false) - // ; - // } - //} public class QuoteConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { entity.HasKey(e => e.QuoteId); - entity.HasMany(d => d.LineItems).WithOne(p => p.Quote); - //entity.HasOne(p => p.Recipient).WithMany(e => e.Quotes); - entity.Property(e => e.DataCreated) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModified) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.QuotationNumber) - .HasColumnType("VARCHAR(255)") - .IsRequired(true) - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.QuotationDate) - .IsRequired(true) - .ValueGeneratedOnAdd() - ; + entity.HasMany(d => d.LineItems).WithOne(p => p.Quote).IsRequired(false).OnDelete(DeleteBehavior.Cascade); + + entity.Property(e => e.QuotationNumber).HasColumnType("VARCHAR(255)").IsRequired(true).ValueGeneratedOnAdd(); + entity.Property(e => e.QuotationDate).IsRequired(true).ValueGeneratedOnAdd(); entity.Property(e => e.ValidUntil); - entity.Property(e => e.ValidFor) - //.HasColumnType("TINYINT") - .IsRequired(true) - ; - //entity.Property(e => e.SalesRep); + entity.Property(e => e.ValidFor).IsRequired(true); + entity.Ignore("SalesRep"); entity.Property(e => e.TotalListprice); entity.Property(e => e.TotalDiscount); entity.Property(e => e.TotalNet); - entity.Property(e => e.VAT) - //.HasDefaultValue("19") - ; + entity.Property(e => e.VAT); entity.Property(e => e.TotalGross); - entity.Property(e => e.QuoteContains3PP) - .HasDefaultValue(false); - entity.Property(e => e.QuoteContainsRB) - .HasDefaultValue(false); + entity.Property(e => e.QuoteContains3PP).HasDefaultValue(false); + entity.Property(e => e.QuoteContainsRB).HasDefaultValue(false); entity.Property(e => e.QuoteTemplate); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -309,55 +120,36 @@ namespace Gremlin.GremlinData.DBClasses { public void Configure(EntityTypeBuilder entity) { - entity.HasKey(e => e.QuoteId); - entity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId); - entity.Property(e => e.DataCreated) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModified) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.Position) - .IsRequired(true) - ; - entity.Property(e => e.Amount) - .IsRequired(true) - ; - entity.Property(e => e.ProductNumber) - .IsRequired(true) - ; + entity.HasKey(e => e.LineItemId); + entity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId).IsRequired(true).OnDelete(DeleteBehavior.Cascade); + + entity.Property(e => e.Position).IsRequired(true); + entity.Property(e => e.Amount).IsRequired(true); + entity.Property(e => e.ProductNumber).IsRequired(true); entity.Property(e => e.OptionNumber); entity.Property(e => e.SapShortDescription); entity.Property(e => e.SapLongDescription); entity.Property(e => e.ProductLine); - entity.Property(e => e.TotalDiscount) - .IsRequired(true) - .HasDefaultValue(0); - entity.Property(e => e.SalesDiscount) - .IsRequired(true) - .HasDefaultValue(0); - entity.Property(e => e.PromotionalDiscount) - .IsRequired(true) - .HasDefaultValue(0); - entity.Property(e => e.ContractualDiscount) - .IsRequired(true) - .HasDefaultValue(0); - entity.Property(e => e.DemoDiscount) - .IsRequired(true) - .HasDefaultValue(0); - entity.Property(e => e.ListPrice) - .IsRequired(true); - entity.Property(e => e.ExtendedListPrice) - .IsRequired(true); - entity.Property(e => e.NetPrice) - .IsRequired(true); - entity.Property(e => e.Total) - .IsRequired(true); + entity.Property(e => e.TotalDiscount).IsRequired(true).HasDefaultValue(0); + entity.Property(e => e.SalesDiscount).IsRequired(true).HasDefaultValue(0); + entity.Property(e => e.PromotionalDiscount).IsRequired(true).HasDefaultValue(0); + entity.Property(e => e.ContractualDiscount).IsRequired(true).HasDefaultValue(0); + entity.Property(e => e.DemoDiscount).IsRequired(true).HasDefaultValue(0); + entity.Property(e => e.ListPrice).IsRequired(true); + entity.Property(e => e.ExtendedListPrice).IsRequired(true); + entity.Property(e => e.NetPrice).IsRequired(true); + entity.Property(e => e.Total).IsRequired(true); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -366,56 +158,28 @@ namespace Gremlin.GremlinData.DBClasses public void Configure(EntityTypeBuilder entity) { entity.HasKey(e => e.ProductId); - entity.HasOne(d => d.CustomDescription).WithOne(p => p.Product); - //entity.HasOne(p => p.ProductLine).WithMany(d => d.Products); - entity.Property(e => e.DataCreationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.DataValidFrom) - .HasColumnType("DATETIME") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationByUser) - .HasColumnType("TINYTEXT") - .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - .ValueGeneratedOnAddOrUpdate() - ; - entity.Property(e => e.DataValidUntil) - .HasColumnType("DATETIME") - .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataVersionNumber) - .HasDefaultValue(1) - .IsRequired(true) - ; - entity.Property(e => e.DataVersionComment) - .HasDefaultValue("") - ; - entity.Property(e => e.DataStatus) - //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - .IsRequired(true) - ; - entity.Property(e => e.ProductNumber) - .IsRequired(true) - ; + entity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).HasForeignKey("CustomDescriptionId").IsRequired(false).OnDelete(DeleteBehavior.Restrict); + entity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey("ProductLineCode").IsRequired(true).OnDelete(DeleteBehavior.Restrict); + + entity.Property(e => e.ProductNumber).IsRequired(true); entity.Property(e => e.OptionNumber); entity.Property(e => e.SapShortDescription); entity.Property(e => e.SapLongDescription); entity.Property(e => e.Weight); entity.Property(e => e.ProductStatus); entity.Property(e => e.IntroductionDate); - entity.Property(e => e.ListPrice) - .IsRequired(true); + entity.Property(e => e.ListPrice).IsRequired(true); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -424,53 +188,26 @@ namespace Gremlin.GremlinData.DBClasses public void Configure(EntityTypeBuilder entity) { entity.HasKey(e => e.CustomDescriptionId); - entity.HasOne(p => p.Product).WithOne(d => d.CustomDescription) - //.HasForeignKey("ProductId") - ; - entity.Property(e => e.DataCreationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.DataValidFrom) - .HasColumnType("DATETIME") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationByUser) - .HasColumnType("TINYTEXT") - .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - ; - entity.Property(e => e.DataValidUntil) - .HasColumnType("DATETIME") - .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataVersionNumber) - .HasDefaultValue(1) - .IsRequired(true) - ; - entity.Property(e => e.DataVersionComment) - .HasDefaultValue("") - ; - entity.Property(e => e.DataStatus) - //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - .IsRequired(true) - ; - entity.Property(e => e.ProductNumber) - .IsRequired(true); + entity.HasMany(p => p.Products).WithOne(d => d.CustomDescription).IsRequired(false); + entity.HasOne(p => p.Supplier).WithMany(d => d.CustomDescriptions).IsRequired(true); + + entity.Property(e => e.ProductNumber).IsRequired(true); entity.Property(e => e.OptionNumber); - entity.Property(e => e.Heading) - .IsRequired(true); + entity.Property(e => e.Heading).IsRequired(true); entity.Property(e => e.DescriptionText); entity.Property(e => e.CoverletterText); entity.Property(e => e.Notes); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -479,43 +216,18 @@ namespace Gremlin.GremlinData.DBClasses public void Configure(EntityTypeBuilder entity) { //entity.HasKey(e => e.ProductLineId); //Property removed. PK is AccountTypeCode (defined via data annotation in class). - entity.HasMany(p => p.Products).WithOne(d => d.ProductLine); - entity.Property(e => e.DataCreationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.DataValidFrom) - .HasColumnType("DATETIME") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationByUser) - .HasColumnType("TINYTEXT") - .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - ; - entity.Property(e => e.DataValidUntil) - .HasColumnType("DATETIME") - .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataVersionNumber) - .HasDefaultValue(1) - .IsRequired(true) - ; - entity.Property(e => e.DataVersionComment) - .HasDefaultValue("") - ; - entity.Property(e => e.DataStatus) - //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - .IsRequired(true) - ; + entity.HasMany(p => p.Products).WithOne(d => d.ProductLine).IsRequired(true).OnDelete(DeleteBehavior.Restrict); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -525,50 +237,19 @@ namespace Gremlin.GremlinData.DBClasses { //entity.HasKey(e => e.AccountTypeCode); //entity.HasMany(p => p.Accounts).WithOne(d => d.AccountType); //already defined in class Account - entity.Property(e => e.DataCreationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.DataValidFrom) - .HasColumnType("DATETIME") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationByUser) - .HasColumnType("TINYTEXT") - .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - ; - entity.Property(e => e.DataValidUntil) - .HasColumnType("DATETIME") - .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataVersionNumber) - .HasDefaultValue(1) - .IsRequired(true) - ; - entity.Property(e => e.DataVersionComment) - .HasDefaultValue("") - ; - entity.Property(e => e.DataStatus) - //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - .IsRequired(true) - ; - entity.Property(e => e.AccountTypeCode) - .IsRequired(true) - .HasColumnType("Char(3)") - ; - entity.Property(e => e.AccountTypeDescription) - .HasColumnType("Varchar(1000)") - //.IsRequired(true) - ; + entity.Property(e => e.AccountTypeCode).IsRequired(true).HasColumnType("Char(3)"); + entity.Property(e => e.AccountTypeDescription).HasColumnType("Varchar(1000)"); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -578,50 +259,19 @@ namespace Gremlin.GremlinData.DBClasses { //entity.HasKey(e => e.SubMarketCode); //entity.HasMany(p => p.Accounts).WithOne(d => d.SubMarket); //already defined in class Account - entity.Property(e => e.DataCreationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationDate) - .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") - .ValueGeneratedOnAddOrUpdate() //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) - .IsConcurrencyToken(true) - ; - entity.Property(e => e.DataValidFrom) - .HasColumnType("DATETIME") - .HasDefaultValueSql("CURRENT_TIMESTAMP") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataModificationByUser) - .HasColumnType("TINYTEXT") - .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - ; - entity.Property(e => e.DataValidUntil) - .HasColumnType("DATETIME") - .HasDefaultValueSql("'9999-12-31 23:59:59.000000'") - .ValueGeneratedOnAdd() - ; - entity.Property(e => e.DataVersionNumber) - .HasDefaultValue(1) - .IsRequired(true) - ; - entity.Property(e => e.DataVersionComment) - .HasDefaultValue("") - ; - entity.Property(e => e.DataStatus) - //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? - .IsRequired(true) - ; - entity.Property(e => e.SubMarketCode) - //.IsRequired(true) //implizit gesetzt durch PK. - .HasColumnType("Char(3)") - ; - entity.Property(e => e.SubMarketDescription) - .HasColumnType("Varchar(1000)") - //.IsRequired(true) - ; + entity.Property(e => e.SubMarketCode).HasColumnType("Char(3)"); + entity.Property(e => e.SubMarketDescription).HasColumnType("Varchar(1000)"); + + entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd(); + entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true); + entity.Property(e => e.DataVersionComment).HasDefaultValue(""); + entity.Property(e => e.DataStatus).IsRequired(true); + //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core? + entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true) + entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -631,13 +281,13 @@ namespace Gremlin.GremlinData.DBClasses { builder.HasKey(e => e.RegisteredUserID); - builder.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); - builder.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); - builder.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); - builder.HasMany(d => d.RUSettings).WithOne(p => p.RegisteredUser).IsRequired(true); builder.Property(e => e.UserName).IsRequired(true); builder.Property(e => e.PasswordHash).IsRequired(true); + + builder.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + builder.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + builder.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } @@ -647,13 +297,13 @@ namespace Gremlin.GremlinData.DBClasses { builder.HasKey(e => e.RUSettingsID); - builder.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); - builder.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); - builder.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); - builder.HasOne(d => d.RegisteredUser).WithMany(p => p.RUSettings).IsRequired(true); builder.Property(e => e.SettingKey).IsRequired(true); builder.Property(e => e.SettingValue).IsRequired(true); + + builder.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd(); + builder.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true); + builder.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); } } } diff --git a/Gremlin/GremlinData/DBClasses/GenericImporter.cs b/Gremlin/GremlinData/DBClasses/GenericImporter.cs index 8ed28b4..ec17e28 100644 --- a/Gremlin/GremlinData/DBClasses/GenericImporter.cs +++ b/Gremlin/GremlinData/DBClasses/GenericImporter.cs @@ -321,7 +321,7 @@ namespace Gremlin.GremlinData.DBClasses DataValidUntil = FarInTheFuture, DataVersionComment = "Initial Importer by CD-ImporterFomCsv", }; - ImportedCD.Product = new(); + ImportedCD.Products = new List(); ImportedCD.Supplier = new(); ImportedCD.Supplier.AccountName = fields[2] is "" or "RB" ? "Agilent Technologies" : fields[2]; ImportedCD.DataCreationDate = ImportedCD.DataValidFrom = ImportedCD.DataModificationDate = DateTime.Now; @@ -378,12 +378,12 @@ namespace Gremlin.GremlinData.DBClasses foreach (CustomDescription CD in CDsReadFromFile) { //Skip Desciptions, if it has been already imported above (as part from 3PP) - if (thirdPartyProductsFromImportedCDs.Contains(CD.Product)) continue; - + if (thirdPartyProductsFromImportedCDs.Intersect(CD.Products).Any()) continue; + //Establish EF Reference. If no PN/Opt found, then skip this custom description. //CD.Product = GetProduct(db, CD.ProductNumber, CD.OptionNumber); //ResolveXY-functions return null, if no match is found in db. - CD.Product = productsInDb.Find(p => p.ProductNumber == CD.ProductNumber && p.OptionNumber == CD.OptionNumber); - if (CD.Product == null) + CD.Products = productsInDb.Where(product => product.ProductNumber == CD.ProductNumber && product.OptionNumber == CD.OptionNumber).ToList(); + if (CD.Products == null) { CDsWithoutEFReferences.Add(CD); continue; diff --git a/Gremlin/GremlinData/EntityClasses/Account.cs b/Gremlin/GremlinData/EntityClasses/Account.cs index 0e027ff..86ae3d2 100644 --- a/Gremlin/GremlinData/EntityClasses/Account.cs +++ b/Gremlin/GremlinData/EntityClasses/Account.cs @@ -10,24 +10,12 @@ namespace Gremlin.GremlinData.EntityClasses public uint AccountId { get; set; } //foreign keys: - public ICollection Contacts { get; set; } - public int? ParentAccountId { get; set; } + public IList Contacts { get; set; } + public uint? ParentAccountId { get; set; } public AccountType AccountType { get; set; } public SubMarket SubMarket { get; set; } - //public int AddressId { get; set; } - //public ICollection MarketsServed { get; set; } - //public ICollection CommunicationChannels { get; set; } - - //standard properties: - public DateTime DataCreationDate { get; set; } - public DateTime DataModificationDate { get; set; } - public DateTime DataValidFrom { get; set; } - public DateTime DataValidUntil { get; set; } - public string DataModificationByUser { get; set; } - public uint DataVersionNumber { get; set; } - public string DataVersionComment { get; set; } - public string DataStatus { get; set; } - + public IList CustomDescriptions { get; set; } + //class properties: public string AccountName { get; set; } public string Notes { get; set; } @@ -43,20 +31,24 @@ namespace Gremlin.GremlinData.EntityClasses public string EMail { get; set; } //Agilent-specific Properties: - //public string AccountTypeCode { get; set; } //enum - //public string AccountSubMarketCode { get; set; } //enum public uint SAPAccountNumber { get; set; } public DateTime AccountCreatedInSAPOn { get; set; } + //metadata: + public DateTime DataCreationDate { get; set; } + public DateTime DataModificationDate { get; set; } + public DateTime DataValidFrom { get; set; } + public DateTime DataValidUntil { get; set; } + public string DataModificationByUser { get; set; } + public uint DataVersionNumber { get; set; } + public string DataVersionComment { get; set; } + public string DataStatus { get; set; } //IBase //tbd public Account() { - //AccountType = new AccountType(); - //SubMarket = new SubMarket(); - //Contacts = new List(); } //public bool Equals(Account other) diff --git a/Gremlin/GremlinData/EntityClasses/AccountType.cs b/Gremlin/GremlinData/EntityClasses/AccountType.cs index c4c87a6..bd880fc 100644 --- a/Gremlin/GremlinData/EntityClasses/AccountType.cs +++ b/Gremlin/GremlinData/EntityClasses/AccountType.cs @@ -14,8 +14,10 @@ namespace Gremlin.GremlinData.EntityClasses //navigation properties: public IList Accounts { get; set; } - //standard properties: - //Ist das hier bei einer de-facto-Enumeration wirklich nötig? + //class properties: + public string AccountTypeDescription { get; set; } + + //metadata: public DateTime DataCreationDate { get; set; } public DateTime DataModificationDate { get; set; } public DateTime DataValidFrom { get; set; } @@ -24,8 +26,5 @@ namespace Gremlin.GremlinData.EntityClasses public uint DataVersionNumber { get; set; } public string DataVersionComment { get; set; } public string DataStatus { get; set; } - - //class properties: - public string AccountTypeDescription { get; set; } } } diff --git a/Gremlin/GremlinData/EntityClasses/Contact.cs b/Gremlin/GremlinData/EntityClasses/Contact.cs index ab85232..ab0b6d7 100644 --- a/Gremlin/GremlinData/EntityClasses/Contact.cs +++ b/Gremlin/GremlinData/EntityClasses/Contact.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Gremlin.GremlinData.EntityClasses { @@ -9,31 +10,15 @@ namespace Gremlin.GremlinData.EntityClasses //foreign keys: public uint AccountId { get; set; } - //public uint QuoteId { get; set; } //navigation properties: public Account Account { get; set; } - //public IList Quotes { get; set; } - - //standard properties: - public DateTime DataCreationDate { get; set; } - public DateTime DataModificationDate { get; set; } - public DateTime DataValidFrom { get; set; } - public DateTime DataValidUntil { get; set; } - public string DataModificationByUser { get; set; } - public uint DataVersionNumber { get; set; } - public string DataVersionComment { get; set; } - public string DataStatus { get; set; } + public IList Quotes { get; set; } //class properties: public string AcademicTitle { get; set; } public string FirstName { get; set; } public string LastName { get; set; } - /// - /// enum Gender - /// - /// 0 = unknown, 1 = male, 2 = female, 3 = divers - /// public byte Gender { get; set; } public bool? OptInStatus { get; set; } public string Department { get; set; } @@ -49,8 +34,7 @@ namespace Gremlin.GremlinData.EntityClasses public bool EmailBounced { get; set; } public bool NoHardcopyMailing { get; set; } public bool ValidatedContact { get; set; } - //public ICollection CommunicationChannels { get; set; } - + //Agilent-specific Properties: public int SAPContactNumber { get; set; } public DateTime SAPContactCreationDate { get; set; } @@ -60,11 +44,19 @@ namespace Gremlin.GremlinData.EntityClasses public string SAPApplicationInterest { get; set; } public string SAPJobLevel { get; set; } public string SAPCompetitiveIBase { get; set; } - public string LinkToSAP { get; set; } - + + //metadata: + public DateTime DataCreationDate { get; set; } + public DateTime DataModificationDate { get; set; } + public DateTime DataValidFrom { get; set; } + public DateTime DataValidUntil { get; set; } + public string DataModificationByUser { get; set; } + public uint DataVersionNumber { get; set; } + public string DataVersionComment { get; set; } + public string DataStatus { get; set; } + public Contact() { - //Account = DbHelper.ResolveAccountById(new GremlinContext(), AccountId); } } } diff --git a/Gremlin/GremlinData/EntityClasses/CustomDescription.cs b/Gremlin/GremlinData/EntityClasses/CustomDescription.cs index 31a93f1..1861aff 100644 --- a/Gremlin/GremlinData/EntityClasses/CustomDescription.cs +++ b/Gremlin/GremlinData/EntityClasses/CustomDescription.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Gremlin.GremlinData.EntityClasses { @@ -6,26 +7,15 @@ namespace Gremlin.GremlinData.EntityClasses { //primary key: public uint CustomDescriptionId { get; set; } - //use composite key PN + Opt instead? - + //foreign keys: - public uint ProductId { get; set; } + //public uint ProductId { get; set; } public uint AccountId { get; set; } //navigation properties: - public Product Product { get; set; } + public IList Products { get; set; } public Account Supplier { get; set; } - //standard properties: - public DateTime DataCreationDate { get; set; } - public DateTime DataModificationDate { get; set; } - public DateTime DataValidFrom { get; set; } - public DateTime DataValidUntil { get; set; } - public string DataModificationByUser { get; set; } - public uint DataVersionNumber { get; set; } - public string DataVersionComment { get; set; } - public string DataStatus { get; set; } - //class properties: public string ProductNumber { get; set; } public string OptionNumber { get; set; } @@ -37,12 +27,19 @@ namespace Gremlin.GremlinData.EntityClasses //Agilent-Specific properties: //NONE + //metadata: + public DateTime DataCreationDate { get; set; } + public DateTime DataModificationDate { get; set; } + public DateTime DataValidFrom { get; set; } + public DateTime DataValidUntil { get; set; } + public string DataModificationByUser { get; set; } + public uint DataVersionNumber { get; set; } + public string DataVersionComment { get; set; } + public string DataStatus { get; set; } //Constructors public CustomDescription() { - //Product = new Product(); - //Supplier = new Account(); } } } diff --git a/Gremlin/GremlinData/EntityClasses/LineItem.cs b/Gremlin/GremlinData/EntityClasses/LineItem.cs index c50cce2..88f3292 100644 --- a/Gremlin/GremlinData/EntityClasses/LineItem.cs +++ b/Gremlin/GremlinData/EntityClasses/LineItem.cs @@ -2,7 +2,7 @@ namespace Gremlin.GremlinData.EntityClasses { - public class LineItem + public class LineItem : IMetadata { //primary key: public uint LineItemId { get; set; } @@ -13,10 +13,6 @@ namespace Gremlin.GremlinData.EntityClasses //navigation properties: public Quote Quote { get; set; } - //standard properties: - public DateTime DataCreated { get; set; } - public DateTime DataModified { get; set; } - //class properties: public ushort Position { get; set; } public ushort Amount { get; set; } @@ -34,5 +30,15 @@ namespace Gremlin.GremlinData.EntityClasses public decimal ExtendedListPrice { get; set; } public decimal NetPrice { get; set; } public decimal Total { get; set; } + + //metadata: + public DateTime DataCreationDate { get; set; } + public string DataModificationByUser { get; set; } + public DateTime DataModificationDate { get; set; } + public string DataStatus { get; set; } + public DateTime DataValidFrom { get; set; } + public DateTime DataValidUntil { get; set; } + public string DataVersionComment { get; set; } + public uint DataVersionNumber { get; set; } } } diff --git a/Gremlin/GremlinData/EntityClasses/LoggedInUser.cs b/Gremlin/GremlinData/EntityClasses/LoggedInUser.cs index 9937267..f3873bb 100644 --- a/Gremlin/GremlinData/EntityClasses/LoggedInUser.cs +++ b/Gremlin/GremlinData/EntityClasses/LoggedInUser.cs @@ -9,7 +9,7 @@ namespace Gremlin.GremlinData.EntityClasses public uint LoggedInUserID { get; set; } //navigation properties - public ICollection LoggedInUserSettings { get; set; } + public IList LoggedInUserSettings { get; set; } //standard properties public DateTime DataCreationDate { get; set; } diff --git a/Gremlin/GremlinData/EntityClasses/Product.cs b/Gremlin/GremlinData/EntityClasses/Product.cs index 08ef892..0ec2f8e 100644 --- a/Gremlin/GremlinData/EntityClasses/Product.cs +++ b/Gremlin/GremlinData/EntityClasses/Product.cs @@ -7,21 +7,15 @@ namespace Gremlin.GremlinData.EntityClasses //primary key: public uint ProductId { get; set; } - //standard properties: - public DateTime DataCreationDate { get; set; } - public DateTime DataModificationDate { get; set; } - public DateTime DataValidFrom { get; set; } - public DateTime DataValidUntil { get; set; } - public string DataModificationByUser { get; set; } - public uint DataVersionNumber { get; set; } - public string DataVersionComment { get; set; } - public string DataStatus { get; set; } - //navigation properties: public CustomDescription CustomDescription { get; set; } public ProductLine ProductLine { get; set; } - //class properties = Agilent-specific properties: + //foreign keys + public uint CustomDescriptionId { get; set; } + public string ProductLineCode { get; set; } + + //Agilent-specific properties: public string ProductNumber { get; set; } public string OptionNumber { get; set; } public string SapShortDescription { get; set; } @@ -34,11 +28,20 @@ namespace Gremlin.GremlinData.EntityClasses public int BreakRangeFrom { get; set; } public int BreakRangeTo { get; set; } + //metadata: + public DateTime DataCreationDate { get; set; } + public DateTime DataModificationDate { get; set; } + public DateTime DataValidFrom { get; set; } + public DateTime DataValidUntil { get; set; } + public string DataModificationByUser { get; set; } + public uint DataVersionNumber { get; set; } + public string DataVersionComment { get; set; } + public string DataStatus { get; set; } + //Constructors public Product() { - //ProductLine = new ProductLine(); } } diff --git a/Gremlin/GremlinData/EntityClasses/ProductLine.cs b/Gremlin/GremlinData/EntityClasses/ProductLine.cs index 1152178..2b89e83 100644 --- a/Gremlin/GremlinData/EntityClasses/ProductLine.cs +++ b/Gremlin/GremlinData/EntityClasses/ProductLine.cs @@ -14,8 +14,10 @@ namespace Gremlin.GremlinData.EntityClasses //navigation properties: public List Products { get; set; } - //standard properties: - //Ist das hier bei einer de-facto-Enumeration wirklich nötig? + //class properties: + public string ProductLineDescription { get; set; } + + //metadata: public DateTime DataCreationDate { get; set; } public DateTime DataModificationDate { get; set; } public DateTime DataValidFrom { get; set; } @@ -24,8 +26,5 @@ namespace Gremlin.GremlinData.EntityClasses public uint DataVersionNumber { get; set; } public string DataVersionComment { get; set; } public string DataStatus { get; set; } - - //class properties: - public string ProductLineDescription { get; set; } } } diff --git a/Gremlin/GremlinData/EntityClasses/Quote.cs b/Gremlin/GremlinData/EntityClasses/Quote.cs index ebae132..63492dc 100644 --- a/Gremlin/GremlinData/EntityClasses/Quote.cs +++ b/Gremlin/GremlinData/EntityClasses/Quote.cs @@ -3,28 +3,24 @@ using System.Collections.Generic; namespace Gremlin.GremlinData.EntityClasses { - public class Quote + public class Quote : IMetadata { //primary key: public uint QuoteId { get; set; } //foreign keys: - public ICollection LineItems { get; set; } + public Contact Recipient { get; set; } + public IList LineItems { get; set; } //navigation properties: //NONE - //standard properties: - public DateTime DataCreated { get; set; } - public DateTime DataModified { get; set; } - //class properties: + public Contact SalesRep { get; set; } public string QuotationNumber { get; set; } public DateTime QuotationDate { get; set; } public DateTime ValidUntil { get; set; } public byte ValidFor { get; set; } - public Contact Recipient { get; set; } - public Contact SalesRep { get; set; } public decimal TotalListprice { get; set; } public decimal TotalDiscount { get; set; } public decimal TotalNet { get; set; } @@ -34,22 +30,18 @@ namespace Gremlin.GremlinData.EntityClasses public bool QuoteContainsRB { get; set; } public string QuoteTemplate { get; set; } + //metadata: + public DateTime DataCreationDate { get; set; } + public string DataModificationByUser { get; set; } + public DateTime DataModificationDate { get; set; } + public string DataStatus { get; set; } + public DateTime DataValidFrom { get; set; } + public DateTime DataValidUntil { get; set; } + public string DataVersionComment { get; set; } + public uint DataVersionNumber { get; set; } + internal Quote() { - ////Initialize - //QuotationDate = DateTime.Now; - ////LineItems = new List(); - //TotalGross = 0; - //TotalListprice = 0; - //TotalDiscount = 0; - //TotalNet = 0; - //QuoteContains3PP = false; - //QuoteContainsRB = false; - - // set quote number - // set validity depending on account classification - // populate SalesRep data (CurrentUser) - // populate Addressee data } } } diff --git a/Gremlin/GremlinData/EntityClasses/RUSetting.cs b/Gremlin/GremlinData/EntityClasses/RUSetting.cs index 285f36a..d3f07f4 100644 --- a/Gremlin/GremlinData/EntityClasses/RUSetting.cs +++ b/Gremlin/GremlinData/EntityClasses/RUSetting.cs @@ -13,15 +13,15 @@ namespace Gremlin.GremlinData.EntityClasses //navigation properties public RegisteredUser RegisteredUser { get; set; } - //standard properties: - public DateTime DataCreationDate { get; set; } - public DateTime DataModificationDate { get; set; } - public string DataModificationByUser { get; set; } - //class properties public string SettingKey { get; set; } public string SettingValue { get; set; } + //metadata (subset of IMetadata) + public DateTime DataCreationDate { get; set; } + public DateTime DataModificationDate { get; set; } + public string DataModificationByUser { get; set; } + //Constructur public RUSetting() { diff --git a/Gremlin/GremlinData/EntityClasses/RegisteredUser.cs b/Gremlin/GremlinData/EntityClasses/RegisteredUser.cs index bccb0ec..0335a9d 100644 --- a/Gremlin/GremlinData/EntityClasses/RegisteredUser.cs +++ b/Gremlin/GremlinData/EntityClasses/RegisteredUser.cs @@ -9,16 +9,16 @@ namespace Gremlin.GremlinData.EntityClasses public uint RegisteredUserID { get; set; } //navigation properties - public ICollection RUSettings { get; set; } - - //standard properties - public DateTime DataCreationDate { get; set; } - public DateTime DataModificationDate { get; set; } - public string DataModificationByUser { get; set; } + public IList RUSettings { get; set; } //class properties public string UserName { get; set; } public string PasswordHash { get; set; } + + //metadata (subset of IMetadata) + public DateTime DataCreationDate { get; set; } + public DateTime DataModificationDate { get; set; } + public string DataModificationByUser { get; set; } //Constructur public RegisteredUser() diff --git a/Gremlin/GremlinData/EntityClasses/SubMarket.cs b/Gremlin/GremlinData/EntityClasses/SubMarket.cs index b404ac8..2bfddaf 100644 --- a/Gremlin/GremlinData/EntityClasses/SubMarket.cs +++ b/Gremlin/GremlinData/EntityClasses/SubMarket.cs @@ -14,8 +14,10 @@ namespace Gremlin.GremlinData.EntityClasses //navigation properties: public IList Accounts { get; set; } - //standard properties: - //Ist das hier bei einer de-facto-Enumeration wirklich nötig? + //class properties: + public string SubMarketDescription { get; set; } + + //metadata public DateTime DataCreationDate { get; set; } public DateTime DataModificationDate { get; set; } public DateTime DataValidFrom { get; set; } @@ -24,8 +26,5 @@ namespace Gremlin.GremlinData.EntityClasses public uint DataVersionNumber { get; set; } public string DataVersionComment { get; set; } public string DataStatus { get; set; } - - //class properties: - public string SubMarketDescription { get; set; } } } diff --git a/Gremlin/Migrations/20210611102249_InitialCreate.Designer.cs b/Gremlin/Migrations/20210628082005_GremlinDb_0.1.0_MVP.Designer.cs similarity index 89% rename from Gremlin/Migrations/20210611102249_InitialCreate.Designer.cs rename to Gremlin/Migrations/20210628082005_GremlinDb_0.1.0_MVP.Designer.cs index 05c951b..dfbc816 100644 --- a/Gremlin/Migrations/20210611102249_InitialCreate.Designer.cs +++ b/Gremlin/Migrations/20210628082005_GremlinDb_0.1.0_MVP.Designer.cs @@ -9,8 +9,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Gremlin.Migrations { [DbContext(typeof(GremlinContext))] - [Migration("20210611102249_InitialCreate")] - partial class InitialCreate + [Migration("20210628082005_GremlinDb_0.1.0_MVP")] + partial class GremlinDb_010_MVP { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -25,7 +25,7 @@ namespace Gremlin.Migrations .ValueGeneratedOnAdd() .HasColumnType("int unsigned"); - b.Property("AccountCreatedinSAPOn") + b.Property("AccountCreatedInSAPOn") .HasColumnType("datetime(6)"); b.Property("AccountName") @@ -103,8 +103,8 @@ namespace Gremlin.Migrations b.Property("Notes") .HasColumnType("longtext"); - b.Property("ParentAccountId") - .HasColumnType("int"); + b.Property("ParentAccountId") + .HasColumnType("int unsigned"); b.Property("PhoneNumber") .IsRequired() @@ -274,9 +274,6 @@ namespace Gremlin.Migrations .IsRequired() .HasColumnType("longtext"); - b.Property("LinkToSAP") - .HasColumnType("longtext"); - b.Property("MobileNumber") .HasColumnType("longtext"); @@ -396,15 +393,12 @@ namespace Gremlin.Migrations .IsRequired() .HasColumnType("longtext"); - b.Property("Note") + b.Property("Notes") .HasColumnType("longtext"); b.Property("OptionNumber") .HasColumnType("longtext"); - b.Property("ProductId") - .HasColumnType("int unsigned"); - b.Property("ProductNumber") .IsRequired() .HasColumnType("longtext"); @@ -413,15 +407,13 @@ namespace Gremlin.Migrations b.HasIndex("AccountId"); - b.HasIndex("ProductId") - .IsUnique(); - b.ToTable("CustomDescriptions"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.LineItem", b => { - b.Property("QuoteId") + b.Property("LineItemId") + .ValueGeneratedOnAdd() .HasColumnType("int unsigned"); b.Property("Amount") @@ -432,17 +424,46 @@ namespace Gremlin.Migrations .HasColumnType("decimal(65,30)") .HasDefaultValue(0m); - b.Property("DataCreated") + b.Property("DataCreationDate") .ValueGeneratedOnAdd() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP"); - b.Property("DataModified") + b.Property("DataModificationByUser") + .ValueGeneratedOnAdd() + .HasColumnType("TINYTEXT") + .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); + + b.Property("DataModificationDate") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + b.Property("DataStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DataValidFrom") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DataValidUntil") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("'9999-12-31 23:59:59.000000'"); + + b.Property("DataVersionComment") + .ValueGeneratedOnAdd() + .HasColumnType("longtext") + .HasDefaultValue(""); + + b.Property("DataVersionNumber") + .ValueGeneratedOnAdd() + .HasColumnType("int unsigned") + .HasDefaultValue(1u); + b.Property("DemoDiscount") .ValueGeneratedOnAdd() .HasColumnType("decimal(65,30)") @@ -451,9 +472,6 @@ namespace Gremlin.Migrations b.Property("ExtendedListPrice") .HasColumnType("decimal(65,30)"); - b.Property("LineItemId") - .HasColumnType("int unsigned"); - b.Property("ListPrice") .HasColumnType("decimal(65,30)"); @@ -478,6 +496,9 @@ namespace Gremlin.Migrations .HasColumnType("decimal(65,30)") .HasDefaultValue(0m); + b.Property("QuoteId") + .HasColumnType("int unsigned"); + b.Property("SalesDiscount") .ValueGeneratedOnAdd() .HasColumnType("decimal(65,30)") @@ -497,7 +518,9 @@ namespace Gremlin.Migrations .HasColumnType("decimal(65,30)") .HasDefaultValue(0m); - b.HasKey("QuoteId"); + b.HasKey("LineItemId"); + + b.HasIndex("QuoteId"); b.ToTable("LineItems"); }); @@ -514,13 +537,16 @@ namespace Gremlin.Migrations b.Property("BreakRangeTo") .HasColumnType("int"); + b.Property("CustomDescriptionId") + .HasColumnType("int unsigned"); + b.Property("DataCreationDate") .ValueGeneratedOnAdd() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("DataModificationByUser") - .ValueGeneratedOnAddOrUpdate() + .ValueGeneratedOnAdd() .HasColumnType("TINYTEXT") .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); @@ -566,8 +592,9 @@ namespace Gremlin.Migrations b.Property("OptionNumber") .HasColumnType("longtext"); - b.Property("ProductLineId") - .HasColumnType("int unsigned"); + b.Property("ProductLineCode") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("ProductNumber") .IsRequired() @@ -587,16 +614,17 @@ namespace Gremlin.Migrations b.HasKey("ProductId"); - b.HasIndex("ProductLineId"); + b.HasIndex("CustomDescriptionId"); + + b.HasIndex("ProductLineCode"); b.ToTable("Products"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.ProductLine", b => { - b.Property("ProductLineId") - .ValueGeneratedOnAdd() - .HasColumnType("int unsigned"); + b.Property("ProductLineCode") + .HasColumnType("varchar(255)"); b.Property("DataCreationDate") .ValueGeneratedOnAdd() @@ -638,13 +666,10 @@ namespace Gremlin.Migrations .HasColumnType("int unsigned") .HasDefaultValue(1u); - b.Property("ProductLineAbbreviation") - .HasColumnType("longtext"); - b.Property("ProductLineDescription") .HasColumnType("longtext"); - b.HasKey("ProductLineId"); + b.HasKey("ProductLineCode"); b.ToTable("ProductLines"); }); @@ -655,17 +680,46 @@ namespace Gremlin.Migrations .ValueGeneratedOnAdd() .HasColumnType("int unsigned"); - b.Property("DataCreated") + b.Property("DataCreationDate") .ValueGeneratedOnAdd() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP"); - b.Property("DataModified") + b.Property("DataModificationByUser") + .ValueGeneratedOnAdd() + .HasColumnType("TINYTEXT") + .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); + + b.Property("DataModificationDate") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + b.Property("DataStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DataValidFrom") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DataValidUntil") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("'9999-12-31 23:59:59.000000'"); + + b.Property("DataVersionComment") + .ValueGeneratedOnAdd() + .HasColumnType("longtext") + .HasDefaultValue(""); + + b.Property("DataVersionNumber") + .ValueGeneratedOnAdd() + .HasColumnType("int unsigned") + .HasDefaultValue(1u); + b.Property("QuotationDate") .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); @@ -852,13 +906,13 @@ namespace Gremlin.Migrations b.HasOne("Gremlin.GremlinData.EntityClasses.AccountType", "AccountType") .WithMany("Accounts") .HasForeignKey("AccountTypeCode") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Gremlin.GremlinData.EntityClasses.SubMarket", "SubMarket") .WithMany("Accounts") .HasForeignKey("SubMarketCode") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("AccountType"); @@ -880,19 +934,11 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.CustomDescription", b => { b.HasOne("Gremlin.GremlinData.EntityClasses.Account", "Supplier") - .WithMany() + .WithMany("CustomDescriptions") .HasForeignKey("AccountId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Gremlin.GremlinData.EntityClasses.Product", "Product") - .WithOne("CustomDescription") - .HasForeignKey("Gremlin.GremlinData.EntityClasses.CustomDescription", "ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - b.Navigation("Supplier"); }); @@ -909,9 +955,18 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Product", b => { + b.HasOne("Gremlin.GremlinData.EntityClasses.CustomDescription", "CustomDescription") + .WithMany("Products") + .HasForeignKey("CustomDescriptionId") + .OnDelete(DeleteBehavior.Restrict); + b.HasOne("Gremlin.GremlinData.EntityClasses.ProductLine", "ProductLine") .WithMany("Products") - .HasForeignKey("ProductLineId"); + .HasForeignKey("ProductLineCode") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CustomDescription"); b.Navigation("ProductLine"); }); @@ -919,7 +974,7 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Quote", b => { b.HasOne("Gremlin.GremlinData.EntityClasses.Contact", "Recipient") - .WithMany() + .WithMany("Quotes") .HasForeignKey("RecipientContactId"); b.Navigation("Recipient"); @@ -939,6 +994,8 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Account", b => { b.Navigation("Contacts"); + + b.Navigation("CustomDescriptions"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.AccountType", b => @@ -946,9 +1003,14 @@ namespace Gremlin.Migrations b.Navigation("Accounts"); }); - modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Product", b => + modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Contact", b => { - b.Navigation("CustomDescription"); + b.Navigation("Quotes"); + }); + + modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.CustomDescription", b => + { + b.Navigation("Products"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.ProductLine", b => diff --git a/Gremlin/Migrations/20210611102249_InitialCreate.cs b/Gremlin/Migrations/20210628082005_GremlinDb_0.1.0_MVP.cs similarity index 88% rename from Gremlin/Migrations/20210611102249_InitialCreate.cs rename to Gremlin/Migrations/20210628082005_GremlinDb_0.1.0_MVP.cs index 2cfe293..4a55aa4 100644 --- a/Gremlin/Migrations/20210611102249_InitialCreate.cs +++ b/Gremlin/Migrations/20210628082005_GremlinDb_0.1.0_MVP.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace Gremlin.Migrations { - public partial class InitialCreate : Migration + public partial class GremlinDb_010_MVP : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -17,6 +17,8 @@ namespace Gremlin.Migrations { AccountTypeCode = table.Column(type: "Char(3)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), + AccountTypeDescription = table.Column(type: "Varchar(1000)", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), @@ -27,8 +29,6 @@ namespace Gremlin.Migrations DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") .Annotation("MySql:CharSet", "utf8mb4"), DataStatus = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - AccountTypeDescription = table.Column(type: "Varchar(1000)", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => @@ -41,8 +41,10 @@ namespace Gremlin.Migrations name: "ProductLines", columns: table => new { - ProductLineId = table.Column(type: "int unsigned", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ProductLineCode = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProductLineDescription = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), @@ -53,15 +55,11 @@ namespace Gremlin.Migrations DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") .Annotation("MySql:CharSet", "utf8mb4"), DataStatus = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ProductLineAbbreviation = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ProductLineDescription = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { - table.PrimaryKey("PK_ProductLines", x => x.ProductLineId); + table.PrimaryKey("PK_ProductLines", x => x.ProductLineCode); }) .Annotation("MySql:CharSet", "utf8mb4"); @@ -71,13 +69,13 @@ namespace Gremlin.Migrations { RegisteredUserID = table.Column(type: "int unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), - DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - .Annotation("MySql:CharSet", "utf8mb4"), UserName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), PasswordHash = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => @@ -92,6 +90,8 @@ namespace Gremlin.Migrations { SubMarketCode = table.Column(type: "Char(3)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), + SubMarketDescription = table.Column(type: "Varchar(1000)", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), @@ -102,8 +102,6 @@ namespace Gremlin.Migrations DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") .Annotation("MySql:CharSet", "utf8mb4"), DataStatus = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SubMarketDescription = table.Column(type: "Varchar(1000)", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => @@ -112,53 +110,6 @@ namespace Gremlin.Migrations }) .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - ProductId = table.Column(type: "int unsigned", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), - DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), - DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - .Annotation("MySql:CharSet", "utf8mb4"), - DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), - DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") - .Annotation("MySql:CharSet", "utf8mb4"), - DataStatus = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ProductLineId = table.Column(type: "int unsigned", nullable: true), - ProductNumber = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - OptionNumber = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SapShortDescription = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SapLongDescription = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Weight = table.Column(type: "float", nullable: false), - ProductStatus = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - IntroductionDate = table.Column(type: "datetime(6)", nullable: false), - ListPrice = table.Column(type: "decimal(65,30)", nullable: false), - HasBreakPrices = table.Column(type: "tinyint(1)", nullable: false), - BreakRangeFrom = table.Column(type: "int", nullable: false), - BreakRangeTo = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.ProductId); - table.ForeignKey( - name: "FK_Products_ProductLines_ProductLineId", - column: x => x.ProductLineId, - principalTable: "ProductLines", - principalColumn: "ProductLineId", - onDelete: ReferentialAction.Restrict); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( name: "RUSettings", columns: table => new @@ -166,13 +117,13 @@ namespace Gremlin.Migrations RUSettingsID = table.Column(type: "int unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), RegisteredUserID = table.Column(type: "int unsigned", nullable: false), - DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), - DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - .Annotation("MySql:CharSet", "utf8mb4"), SettingKey = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SettingValue = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => @@ -193,22 +144,11 @@ namespace Gremlin.Migrations { AccountId = table.Column(type: "int unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ParentAccountId = table.Column(type: "int", nullable: true), + ParentAccountId = table.Column(type: "int unsigned", nullable: true), AccountTypeCode = table.Column(type: "Char(3)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SubMarketCode = table.Column(type: "Char(3)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), - DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), - DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), - DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - .Annotation("MySql:CharSet", "utf8mb4"), - DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), - DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") - .Annotation("MySql:CharSet", "utf8mb4"), - DataStatus = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), AccountName = table.Column(type: "varchar(250)", maxLength: 250, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Notes = table.Column(type: "longtext", nullable: true) @@ -232,7 +172,18 @@ namespace Gremlin.Migrations EMail = table.Column(type: "varchar(150)", maxLength: 150, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), SAPAccountNumber = table.Column(type: "int unsigned", nullable: false), - AccountCreatedinSAPOn = table.Column(type: "datetime(6)", nullable: false) + AccountCreatedInSAPOn = table.Column(type: "datetime(6)", nullable: false), + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") + .Annotation("MySql:CharSet", "utf8mb4"), + DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), + DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"), + DataStatus = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { @@ -243,13 +194,13 @@ namespace Gremlin.Migrations column: x => x.AccountTypeCode, principalTable: "AccountTypes", principalColumn: "AccountTypeCode", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Accounts_SubMarkets_SubMarketCode", column: x => x.SubMarketCode, principalTable: "SubMarkets", principalColumn: "SubMarketCode", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); @@ -260,17 +211,6 @@ namespace Gremlin.Migrations ContactId = table.Column(type: "int unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), AccountId = table.Column(type: "int unsigned", nullable: false), - DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), - DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), - DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - .Annotation("MySql:CharSet", "utf8mb4"), - DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), - DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") - .Annotation("MySql:CharSet", "utf8mb4"), - DataStatus = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), AcademicTitle = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), FirstName = table.Column(type: "longtext", nullable: true) @@ -313,7 +253,16 @@ namespace Gremlin.Migrations .Annotation("MySql:CharSet", "utf8mb4"), SAPCompetitiveIBase = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), - LinkToSAP = table.Column(type: "longtext", nullable: true) + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") + .Annotation("MySql:CharSet", "utf8mb4"), + DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), + DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"), + DataStatus = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => @@ -334,19 +283,7 @@ namespace Gremlin.Migrations { CustomDescriptionId = table.Column(type: "int unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ProductId = table.Column(type: "int unsigned", nullable: false), AccountId = table.Column(type: "int unsigned", nullable: false), - DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), - DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), - DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") - .Annotation("MySql:CharSet", "utf8mb4"), - DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), - DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") - .Annotation("MySql:CharSet", "utf8mb4"), - DataStatus = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), ProductNumber = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), OptionNumber = table.Column(type: "longtext", nullable: true) @@ -357,7 +294,18 @@ namespace Gremlin.Migrations .Annotation("MySql:CharSet", "utf8mb4"), CoverletterText = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), - Note = table.Column(type: "longtext", nullable: true) + Notes = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") + .Annotation("MySql:CharSet", "utf8mb4"), + DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), + DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"), + DataStatus = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => @@ -369,12 +317,6 @@ namespace Gremlin.Migrations principalTable: "Accounts", principalColumn: "AccountId", onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_CustomDescriptions_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "ProductId", - onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); @@ -384,15 +326,13 @@ namespace Gremlin.Migrations { QuoteId = table.Column(type: "int unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DataCreated = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModified = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + RecipientContactId = table.Column(type: "int unsigned", nullable: true), QuotationNumber = table.Column(type: "VARCHAR(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), QuotationDate = table.Column(type: "datetime(6)", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ValidUntil = table.Column(type: "datetime(6)", nullable: false), ValidFor = table.Column(type: "tinyint unsigned", nullable: false), - RecipientContactId = table.Column(type: "int unsigned", nullable: true), TotalListprice = table.Column(type: "decimal(65,30)", nullable: false), TotalDiscount = table.Column(type: "decimal(65,30)", nullable: false), TotalNet = table.Column(type: "decimal(65,30)", nullable: false), @@ -401,7 +341,18 @@ namespace Gremlin.Migrations QuoteContains3PP = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), QuoteContainsRB = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), QuoteTemplate = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") + .Annotation("MySql:CharSet", "utf8mb4"), + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") + .Annotation("MySql:CharSet", "utf8mb4"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataStatus = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), + DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"), + DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u) }, constraints: table => { @@ -415,14 +366,68 @@ namespace Gremlin.Migrations }) .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + ProductId = table.Column(type: "int unsigned", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CustomDescriptionId = table.Column(type: "int unsigned", nullable: false), + ProductLineCode = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProductNumber = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + OptionNumber = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SapShortDescription = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SapLongDescription = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Weight = table.Column(type: "float", nullable: false), + ProductStatus = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IntroductionDate = table.Column(type: "datetime(6)", nullable: false), + ListPrice = table.Column(type: "decimal(65,30)", nullable: false), + HasBreakPrices = table.Column(type: "tinyint(1)", nullable: false), + BreakRangeFrom = table.Column(type: "int", nullable: false), + BreakRangeTo = table.Column(type: "int", nullable: false), + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") + .Annotation("MySql:CharSet", "utf8mb4"), + DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u), + DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"), + DataStatus = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.ProductId); + table.ForeignKey( + name: "FK_Products_CustomDescriptions_CustomDescriptionId", + column: x => x.CustomDescriptionId, + principalTable: "CustomDescriptions", + principalColumn: "CustomDescriptionId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Products_ProductLines_ProductLineCode", + column: x => x.ProductLineCode, + principalTable: "ProductLines", + principalColumn: "ProductLineCode", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( name: "LineItems", columns: table => new { + LineItemId = table.Column(type: "int unsigned", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), QuoteId = table.Column(type: "int unsigned", nullable: false), - LineItemId = table.Column(type: "int unsigned", nullable: false), - DataCreated = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - DataModified = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), Position = table.Column(type: "smallint unsigned", nullable: false), Amount = table.Column(type: "smallint unsigned", nullable: false), ProductNumber = table.Column(type: "longtext", nullable: false) @@ -443,11 +448,22 @@ namespace Gremlin.Migrations ListPrice = table.Column(type: "decimal(65,30)", nullable: false), ExtendedListPrice = table.Column(type: "decimal(65,30)", nullable: false), NetPrice = table.Column(type: "decimal(65,30)", nullable: false), - Total = table.Column(type: "decimal(65,30)", nullable: false) + Total = table.Column(type: "decimal(65,30)", nullable: false), + DataCreationDate = table.Column(type: "TIMESTAMP", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataModificationByUser = table.Column(type: "TINYTEXT", nullable: true, defaultValueSql: "ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()") + .Annotation("MySql:CharSet", "utf8mb4"), + DataModificationDate = table.Column(type: "TIMESTAMP", rowVersion: true, nullable: false, defaultValueSql: "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), + DataStatus = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DataValidFrom = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DataValidUntil = table.Column(type: "DATETIME", nullable: false, defaultValueSql: "'9999-12-31 23:59:59.000000'"), + DataVersionComment = table.Column(type: "longtext", nullable: true, defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"), + DataVersionNumber = table.Column(type: "int unsigned", nullable: false, defaultValue: 1u) }, constraints: table => { - table.PrimaryKey("PK_LineItems", x => x.QuoteId); + table.PrimaryKey("PK_LineItems", x => x.LineItemId); table.ForeignKey( name: "FK_LineItems_Quotes_QuoteId", column: x => x.QuoteId, @@ -478,15 +494,19 @@ namespace Gremlin.Migrations column: "AccountId"); migrationBuilder.CreateIndex( - name: "IX_CustomDescriptions_ProductId", - table: "CustomDescriptions", - column: "ProductId", - unique: true); + name: "IX_LineItems_QuoteId", + table: "LineItems", + column: "QuoteId"); + + migrationBuilder.CreateIndex( + name: "IX_Products_CustomDescriptionId", + table: "Products", + column: "CustomDescriptionId"); migrationBuilder.CreateIndex( - name: "IX_Products_ProductLineId", + name: "IX_Products_ProductLineCode", table: "Products", - column: "ProductLineId"); + column: "ProductLineCode"); migrationBuilder.CreateIndex( name: "IX_Quotes_RecipientContactId", @@ -501,27 +521,27 @@ namespace Gremlin.Migrations protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DropTable( - name: "CustomDescriptions"); - migrationBuilder.DropTable( name: "LineItems"); migrationBuilder.DropTable( - name: "RUSettings"); + name: "Products"); migrationBuilder.DropTable( - name: "Products"); + name: "RUSettings"); migrationBuilder.DropTable( name: "Quotes"); migrationBuilder.DropTable( - name: "RegisteredUser"); + name: "CustomDescriptions"); migrationBuilder.DropTable( name: "ProductLines"); + migrationBuilder.DropTable( + name: "RegisteredUser"); + migrationBuilder.DropTable( name: "Contacts"); diff --git a/Gremlin/Migrations/GremlinContextModelSnapshot.cs b/Gremlin/Migrations/GremlinContextModelSnapshot.cs index 9fd3e42..1cb727a 100644 --- a/Gremlin/Migrations/GremlinContextModelSnapshot.cs +++ b/Gremlin/Migrations/GremlinContextModelSnapshot.cs @@ -23,7 +23,7 @@ namespace Gremlin.Migrations .ValueGeneratedOnAdd() .HasColumnType("int unsigned"); - b.Property("AccountCreatedinSAPOn") + b.Property("AccountCreatedInSAPOn") .HasColumnType("datetime(6)"); b.Property("AccountName") @@ -101,8 +101,8 @@ namespace Gremlin.Migrations b.Property("Notes") .HasColumnType("longtext"); - b.Property("ParentAccountId") - .HasColumnType("int"); + b.Property("ParentAccountId") + .HasColumnType("int unsigned"); b.Property("PhoneNumber") .IsRequired() @@ -272,9 +272,6 @@ namespace Gremlin.Migrations .IsRequired() .HasColumnType("longtext"); - b.Property("LinkToSAP") - .HasColumnType("longtext"); - b.Property("MobileNumber") .HasColumnType("longtext"); @@ -394,15 +391,12 @@ namespace Gremlin.Migrations .IsRequired() .HasColumnType("longtext"); - b.Property("Note") + b.Property("Notes") .HasColumnType("longtext"); b.Property("OptionNumber") .HasColumnType("longtext"); - b.Property("ProductId") - .HasColumnType("int unsigned"); - b.Property("ProductNumber") .IsRequired() .HasColumnType("longtext"); @@ -411,15 +405,13 @@ namespace Gremlin.Migrations b.HasIndex("AccountId"); - b.HasIndex("ProductId") - .IsUnique(); - b.ToTable("CustomDescriptions"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.LineItem", b => { - b.Property("QuoteId") + b.Property("LineItemId") + .ValueGeneratedOnAdd() .HasColumnType("int unsigned"); b.Property("Amount") @@ -430,17 +422,46 @@ namespace Gremlin.Migrations .HasColumnType("decimal(65,30)") .HasDefaultValue(0m); - b.Property("DataCreated") + b.Property("DataCreationDate") .ValueGeneratedOnAdd() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP"); - b.Property("DataModified") + b.Property("DataModificationByUser") + .ValueGeneratedOnAdd() + .HasColumnType("TINYTEXT") + .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); + + b.Property("DataModificationDate") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + b.Property("DataStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DataValidFrom") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DataValidUntil") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("'9999-12-31 23:59:59.000000'"); + + b.Property("DataVersionComment") + .ValueGeneratedOnAdd() + .HasColumnType("longtext") + .HasDefaultValue(""); + + b.Property("DataVersionNumber") + .ValueGeneratedOnAdd() + .HasColumnType("int unsigned") + .HasDefaultValue(1u); + b.Property("DemoDiscount") .ValueGeneratedOnAdd() .HasColumnType("decimal(65,30)") @@ -449,9 +470,6 @@ namespace Gremlin.Migrations b.Property("ExtendedListPrice") .HasColumnType("decimal(65,30)"); - b.Property("LineItemId") - .HasColumnType("int unsigned"); - b.Property("ListPrice") .HasColumnType("decimal(65,30)"); @@ -476,6 +494,9 @@ namespace Gremlin.Migrations .HasColumnType("decimal(65,30)") .HasDefaultValue(0m); + b.Property("QuoteId") + .HasColumnType("int unsigned"); + b.Property("SalesDiscount") .ValueGeneratedOnAdd() .HasColumnType("decimal(65,30)") @@ -495,7 +516,9 @@ namespace Gremlin.Migrations .HasColumnType("decimal(65,30)") .HasDefaultValue(0m); - b.HasKey("QuoteId"); + b.HasKey("LineItemId"); + + b.HasIndex("QuoteId"); b.ToTable("LineItems"); }); @@ -512,13 +535,16 @@ namespace Gremlin.Migrations b.Property("BreakRangeTo") .HasColumnType("int"); + b.Property("CustomDescriptionId") + .HasColumnType("int unsigned"); + b.Property("DataCreationDate") .ValueGeneratedOnAdd() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("DataModificationByUser") - .ValueGeneratedOnAddOrUpdate() + .ValueGeneratedOnAdd() .HasColumnType("TINYTEXT") .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); @@ -564,8 +590,9 @@ namespace Gremlin.Migrations b.Property("OptionNumber") .HasColumnType("longtext"); - b.Property("ProductLineId") - .HasColumnType("int unsigned"); + b.Property("ProductLineCode") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("ProductNumber") .IsRequired() @@ -585,16 +612,17 @@ namespace Gremlin.Migrations b.HasKey("ProductId"); - b.HasIndex("ProductLineId"); + b.HasIndex("CustomDescriptionId"); + + b.HasIndex("ProductLineCode"); b.ToTable("Products"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.ProductLine", b => { - b.Property("ProductLineId") - .ValueGeneratedOnAdd() - .HasColumnType("int unsigned"); + b.Property("ProductLineCode") + .HasColumnType("varchar(255)"); b.Property("DataCreationDate") .ValueGeneratedOnAdd() @@ -636,13 +664,10 @@ namespace Gremlin.Migrations .HasColumnType("int unsigned") .HasDefaultValue(1u); - b.Property("ProductLineAbbreviation") - .HasColumnType("longtext"); - b.Property("ProductLineDescription") .HasColumnType("longtext"); - b.HasKey("ProductLineId"); + b.HasKey("ProductLineCode"); b.ToTable("ProductLines"); }); @@ -653,17 +678,46 @@ namespace Gremlin.Migrations .ValueGeneratedOnAdd() .HasColumnType("int unsigned"); - b.Property("DataCreated") + b.Property("DataCreationDate") .ValueGeneratedOnAdd() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP"); - b.Property("DataModified") + b.Property("DataModificationByUser") + .ValueGeneratedOnAdd() + .HasColumnType("TINYTEXT") + .HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()"); + + b.Property("DataModificationDate") .IsConcurrencyToken() .ValueGeneratedOnAddOrUpdate() .HasColumnType("TIMESTAMP") .HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + b.Property("DataStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DataValidFrom") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DataValidUntil") + .ValueGeneratedOnAdd() + .HasColumnType("DATETIME") + .HasDefaultValueSql("'9999-12-31 23:59:59.000000'"); + + b.Property("DataVersionComment") + .ValueGeneratedOnAdd() + .HasColumnType("longtext") + .HasDefaultValue(""); + + b.Property("DataVersionNumber") + .ValueGeneratedOnAdd() + .HasColumnType("int unsigned") + .HasDefaultValue(1u); + b.Property("QuotationDate") .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); @@ -850,13 +904,13 @@ namespace Gremlin.Migrations b.HasOne("Gremlin.GremlinData.EntityClasses.AccountType", "AccountType") .WithMany("Accounts") .HasForeignKey("AccountTypeCode") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Gremlin.GremlinData.EntityClasses.SubMarket", "SubMarket") .WithMany("Accounts") .HasForeignKey("SubMarketCode") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("AccountType"); @@ -878,19 +932,11 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.CustomDescription", b => { b.HasOne("Gremlin.GremlinData.EntityClasses.Account", "Supplier") - .WithMany() + .WithMany("CustomDescriptions") .HasForeignKey("AccountId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Gremlin.GremlinData.EntityClasses.Product", "Product") - .WithOne("CustomDescription") - .HasForeignKey("Gremlin.GremlinData.EntityClasses.CustomDescription", "ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - b.Navigation("Supplier"); }); @@ -907,9 +953,18 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Product", b => { + b.HasOne("Gremlin.GremlinData.EntityClasses.CustomDescription", "CustomDescription") + .WithMany("Products") + .HasForeignKey("CustomDescriptionId") + .OnDelete(DeleteBehavior.Restrict); + b.HasOne("Gremlin.GremlinData.EntityClasses.ProductLine", "ProductLine") .WithMany("Products") - .HasForeignKey("ProductLineId"); + .HasForeignKey("ProductLineCode") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CustomDescription"); b.Navigation("ProductLine"); }); @@ -917,7 +972,7 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Quote", b => { b.HasOne("Gremlin.GremlinData.EntityClasses.Contact", "Recipient") - .WithMany() + .WithMany("Quotes") .HasForeignKey("RecipientContactId"); b.Navigation("Recipient"); @@ -937,6 +992,8 @@ namespace Gremlin.Migrations modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Account", b => { b.Navigation("Contacts"); + + b.Navigation("CustomDescriptions"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.AccountType", b => @@ -944,9 +1001,14 @@ namespace Gremlin.Migrations b.Navigation("Accounts"); }); - modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Product", b => + modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.Contact", b => { - b.Navigation("CustomDescription"); + b.Navigation("Quotes"); + }); + + modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.CustomDescription", b => + { + b.Navigation("Products"); }); modelBuilder.Entity("Gremlin.GremlinData.EntityClasses.ProductLine", b =>