Skip to content

Commit

Permalink
fix: Fix EF validation runtime warnings (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
akak1977 authored Oct 6, 2022
1 parent e0f350a commit bfcd69a
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace VirtoCommerce.PricingModule.Data.Repositories
{
public class PricingDbContext : DbContextWithTriggers
{
#pragma warning disable S109
public PricingDbContext(DbContextOptions<PricingDbContext> options)
: base(options)
{
Expand All @@ -22,6 +23,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<PriceEntity>().Property(x => x.Id).HasMaxLength(128).ValueGeneratedOnAdd();
modelBuilder.Entity<PriceEntity>().HasOne(x => x.Pricelist).WithMany(x => x.Prices).IsRequired().HasForeignKey(x => x.PricelistId);
modelBuilder.Entity<PriceEntity>().HasIndex(x => new { x.PricelistId, x.ProductId, x.StartDate, x.EndDate }).HasDatabaseName("IX_PricelistProductDates");
modelBuilder.Entity<PriceEntity>().Property(x => x.MinQuantity).HasPrecision(18, 2);
modelBuilder.Entity<PriceEntity>();

modelBuilder.Entity<PricelistEntity>().ToTable("Pricelist").HasKey(x => x.Id);
Expand All @@ -34,8 +36,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

// ugly hack because EFCore removed ultra useful DbQuery type in 3.0
modelBuilder.Entity<MergedPriceEntity>().HasNoKey().ToView("empty");
modelBuilder.Entity<MergedPriceEntity>().Property(x => x.List).HasPrecision(18, 2);
modelBuilder.Entity<MergedPriceEntity>().Property(x => x.MinQuantity).HasPrecision(18, 2);
modelBuilder.Entity<MergedPriceEntity>().Property(x => x.Sale).HasPrecision(18, 2);

base.OnModelCreating(modelBuilder);
}
#pragma warning restore S109
}
}

0 comments on commit bfcd69a

Please sign in to comment.