using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Gremlin_BlazorServer.Data.DBClasses
{
	public class AccountConfiguration : IEntityTypeConfiguration<Account>
	{
		public void Configure(EntityTypeBuilder<Account> accountEntity)
		{
			_ = accountEntity.HasKey(e => e.AccountId);
			_ = accountEntity.HasMany(d => d.Contacts).WithOne(p => p.Account).IsRequired(true);
			_ = accountEntity.HasOne(d => d.AccountType).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
			_ = accountEntity.HasOne(d => d.SubMarket).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
			_ = accountEntity.HasAlternateKey(e => e.SAPAccountNumber);        // =Unique

			_ = accountEntity.Property(e => e.AccountId).ValueGeneratedOnAdd();
			_ = accountEntity.Property(e => e.ParentAccountId).HasDefaultValue(0);
			_ = accountEntity.Property(e => e.AccountName).IsRequired(true).HasMaxLength(250);
			_ = accountEntity.Property(e => e.Notes).HasDefaultValue("");
			_ = accountEntity.Property(e => e.Street).IsRequired(true).HasMaxLength(100);
			_ = accountEntity.Property(e => e.ZIP).IsRequired(true).HasColumnType("Char(5)");
			_ = accountEntity.Property(e => e.City).IsRequired(true).HasMaxLength(50);
			_ = accountEntity.Property(e => e.FloorOrBuilding).HasMaxLength(50);
			_ = accountEntity.Property(e => e.Longitude).HasDefaultValue(0);
			_ = accountEntity.Property(e => e.Latitude).HasDefaultValue(0);
			_ = accountEntity.Property(e => e.PhoneNumber).IsRequired(true).HasMaxLength(30);
			_ = accountEntity.Property(e => e.FaxNumber).HasMaxLength(30).HasDefaultValue("");
			_ = accountEntity.Property(e => e.Webpage).HasMaxLength(250).HasDefaultValue("");
			_ = accountEntity.Property(e => e.EMail).HasMaxLength(150).HasDefaultValue("");
			_ = accountEntity.Property(e => e.SAPAccountNumber).IsRequired(true);
			_ = accountEntity.Property(e => e.AccountCreatedInSAPOn).IsRequired(true);

			_ = accountEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = accountEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = accountEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = accountEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = accountEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = accountEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
			//.HasDefaultValue("Active")  //Default-Wert wird nicht gesetzt?!? Bug in EF Core?
			_ = accountEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			//.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true)
			_ = accountEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class ContactConfiguration : IEntityTypeConfiguration<Contact>
	{
		public void Configure(EntityTypeBuilder<Contact> contactEntity)
		{
			_ = contactEntity.HasKey(e => e.ContactId);
			_ = contactEntity.HasOne(p => p.Account).WithMany(d => d.Contacts).IsRequired(true);
			//entity.HasAlternateKey(e => e.SAPContactNumber);

			_ = contactEntity.Property(e => e.ContactId);
			_ = contactEntity.Property(e => e.SAPContactNumber).IsRequired(true);
			_ = contactEntity.Property(e => e.AcademicTitle).HasDefaultValue("");
			_ = contactEntity.Property(e => e.FirstName).HasDefaultValue("");
			_ = contactEntity.Property(e => e.LastName).IsRequired(true);
			_ = contactEntity.Property(e => e.Gender).HasDefaultValue(0);
			//.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).
			_ = contactEntity.Property(e => e.OptInStatus).HasDefaultValue(false);
			_ = contactEntity.Property(e => e.IsReference).HasDefaultValue(false);
			_ = contactEntity.Property(e => e.Notes).HasDefaultValue("");
			_ = contactEntity.Property(e => e.ValidatedContact).HasDefaultValue(false);

			_ = contactEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = contactEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = contactEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = contactEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = contactEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = contactEntity.Property(e => e.DataStatus).IsRequired(true);
			//.HasDefaultValue("Active")  //Default-Wert wird nicht gesetzt?!? Bug in EF Core?
			_ = contactEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			//.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true)
			_ = contactEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class QuoteConfiguration : IEntityTypeConfiguration<Quote>
	{
		public void Configure(EntityTypeBuilder<Quote> quoteEntity)
		{
			_ = quoteEntity.HasKey(e => e.QuoteId);
			_ = quoteEntity.HasMany(d => d.LineItems).WithOne(p => p.Quote).IsRequired(false).OnDelete(DeleteBehavior.Cascade);

			_ = quoteEntity.Property(e => e.QuotationNumber).HasColumnType("VARCHAR(255)").IsRequired(true).ValueGeneratedOnAdd();
			_ = quoteEntity.Property(e => e.QuotationDate).IsRequired(true).ValueGeneratedOnAdd();
			_ = quoteEntity.Property(e => e.ValidUntil);
			_ = quoteEntity.Property(e => e.ValidFor).IsRequired(true);

			_ = quoteEntity.Ignore("SalesRep");

			_ = quoteEntity.Property(e => e.TotalListprice);
			_ = quoteEntity.Property(e => e.TotalDiscount);
			_ = quoteEntity.Property(e => e.TotalNet);
			_ = quoteEntity.Property(e => e.VAT);
			_ = quoteEntity.Property(e => e.TotalGross);
			_ = quoteEntity.Property(e => e.QuoteContains3PP).HasDefaultValue(false);
			_ = quoteEntity.Property(e => e.QuoteContainsRB).HasDefaultValue(false);
			_ = quoteEntity.Property(e => e.QuoteTemplate).HasDefaultValue("");

			_ = quoteEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = quoteEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = quoteEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = quoteEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = quoteEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = quoteEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active"); ;
			_ = quoteEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = quoteEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class LineItemConfiguration : IEntityTypeConfiguration<LineItem>
	{
		public void Configure(EntityTypeBuilder<LineItem> entity)
		{
			_ = 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).HasDefaultValue("");
			_ = entity.Property(e => e.SapShortDescription).HasDefaultValue("");
			_ = entity.Property(e => e.SapLongDescription).HasDefaultValue("");
			_ = entity.Property(e => e.ProductLine).HasDefaultValue("");
			_ = 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");
			_ = entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class ProductConfiguration : IEntityTypeConfiguration<Product>
	{
		public void Configure(EntityTypeBuilder<Product> productEntity)
		{
			_ = productEntity.HasKey(e => e.ProductId);
			_ = productEntity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).HasForeignKey("CustomDescriptionId").IsRequired(true).OnDelete(DeleteBehavior.SetNull);
			_ = productEntity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey("ProductLineCode").IsRequired(true).OnDelete(DeleteBehavior.Restrict);

			_ = productEntity.Property(e => e.CustomDescriptionId).IsRequired(true);

			_ = productEntity.Property(e => e.ProductNumber).IsRequired(true);
			_ = productEntity.Property(e => e.OptionNumber).HasDefaultValue("");
			_ = productEntity.Property(e => e.SapShortDescription).HasDefaultValue("");
			_ = productEntity.Property(e => e.SapLongDescription).HasDefaultValue("");
			_ = productEntity.Property(e => e.Weight).HasDefaultValue(0);
			_ = productEntity.Property(e => e.ProductStatus).HasDefaultValue("Active");
			_ = productEntity.Property(e => e.IntroductionDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = productEntity.Property(e => e.ListPrice).IsRequired(true);

			_ = productEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = productEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = productEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = productEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = productEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = productEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
			_ = productEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = productEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class CustomDescriptionConfiguration : IEntityTypeConfiguration<CustomDescription>
	{
		public void Configure(EntityTypeBuilder<CustomDescription> customDescriptionEntity)
		{
			_ = customDescriptionEntity.HasKey(e => e.CustomDescriptionId);
			_ = customDescriptionEntity.HasMany(p => p.Products).WithOne(d => d.CustomDescription).IsRequired(false);
			_ = customDescriptionEntity.HasOne(p => p.Supplier).WithMany(d => d.CustomDescriptions).IsRequired(true);

			_ = customDescriptionEntity.Property(e => e.ProductNumber).IsRequired(true);
			_ = customDescriptionEntity.Property(e => e.OptionNumber).HasDefaultValue("");
			_ = customDescriptionEntity.Property(e => e.Heading).IsRequired(true);
			_ = customDescriptionEntity.Property(e => e.DescriptionText).HasDefaultValue("");
			_ = customDescriptionEntity.Property(e => e.CoverletterText).HasDefaultValue("");
			_ = customDescriptionEntity.Property(e => e.Notes).HasDefaultValue("");

			_ = customDescriptionEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = customDescriptionEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = customDescriptionEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = customDescriptionEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = customDescriptionEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = customDescriptionEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
			_ = customDescriptionEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = customDescriptionEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class ProductLineConfiguration : IEntityTypeConfiguration<ProductLine>
	{
		public void Configure(EntityTypeBuilder<ProductLine> productLineEntity)
		{
			_ = productLineEntity.HasMany(p => p.Products).WithOne(d => d.ProductLine).IsRequired(true).OnDelete(DeleteBehavior.Restrict);

			_ = productLineEntity.Property(e => e.ProductLineDescription).IsRequired(true);

			_ = productLineEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = productLineEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = productLineEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = productLineEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = productLineEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = productLineEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
			_ = productLineEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = productLineEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class AccountTypeConfiguration : IEntityTypeConfiguration<AccountType>
	{
		public void Configure(EntityTypeBuilder<AccountType> accountTypeEntity)
		{
			//entity.HasKey(e => e.AccountTypeCode);
			//entity.HasMany(p => p.Accounts).WithOne(d => d.AccountType); //already defined in class Account
			_ = accountTypeEntity.Property(e => e.AccountTypeCode).IsRequired(true).HasColumnType("Char(3)");
			_ = accountTypeEntity.Property(e => e.AccountTypeDescription).HasColumnType("Varchar(1000)").IsRequired(true);

			_ = accountTypeEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = accountTypeEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = accountTypeEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = accountTypeEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = accountTypeEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = accountTypeEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
			_ = accountTypeEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = accountTypeEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class SubMarketConfiguration : IEntityTypeConfiguration<SubMarket>
	{
		public void Configure(EntityTypeBuilder<SubMarket> subMarketEntity)
		{
			//entity.HasKey(e => e.SubMarketCode);
			//entity.HasMany(p => p.Accounts).WithOne(d => d.SubMarket);  //already defined in class Account
			_ = subMarketEntity.Property(e => e.SubMarketCode).HasColumnType("Char(3)");
			_ = subMarketEntity.Property(e => e.SubMarketDescription).HasColumnType("Varchar(1000)").IsRequired(true);

			_ = subMarketEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = subMarketEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = subMarketEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
			_ = subMarketEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
			_ = subMarketEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
			_ = subMarketEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
			_ = subMarketEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = subMarketEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class RegisteredUserConfiguration : IEntityTypeConfiguration<RegisteredUser>
	{
		public void Configure(EntityTypeBuilder<RegisteredUser> registeredUserEntity)
		{
			_ = registeredUserEntity.HasKey(e => e.RegisteredUserID);

			_ = registeredUserEntity.HasMany(d => d.RUSettings).WithOne(p => p.RegisteredUser).IsRequired(true);
			_ = registeredUserEntity.Property(e => e.UserName).IsRequired(true);
			_ = registeredUserEntity.Property(e => e.PasswordHash).IsRequired(true);

			_ = registeredUserEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = registeredUserEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = registeredUserEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}

	public class RUSettingsConfiguration : IEntityTypeConfiguration<RUSettings>
	{
		public void Configure(EntityTypeBuilder<RUSettings> rUSettingsEntitity)
		{
			_ = rUSettingsEntitity.HasKey(e => e.RUSettingsID);

			_ = rUSettingsEntitity.HasOne(d => d.RegisteredUser).WithMany(p => p.RUSettings).IsRequired(true);
			_ = rUSettingsEntitity.Property(e => e.SettingKey).IsRequired(true);
			_ = rUSettingsEntitity.Property(e => e.SettingValue).IsRequired(true);

			_ = rUSettingsEntitity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
			_ = rUSettingsEntitity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
			_ = rUSettingsEntitity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
		}
	}
}
