From 6b457d911b15da7b6a914fe1065cfc37569db367 Mon Sep 17 00:00:00 2001 From: Nikoo Asadnejad Date: Fri, 3 May 2024 11:49:42 +0330 Subject: [PATCH] feat: add entity configurations to context --- Src/Product.Infrastructure/Data/Context/CommandContext.cs | 5 ++++- Src/Product.Infrastructure/Data/Context/QueryContext.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/Product.Infrastructure/Data/Context/CommandContext.cs b/Src/Product.Infrastructure/Data/Context/CommandContext.cs index 4c506b0..b6dd5e0 100644 --- a/Src/Product.Infrastructure/Data/Context/CommandContext.cs +++ b/Src/Product.Infrastructure/Data/Context/CommandContext.cs @@ -4,5 +4,8 @@ namespace Product.Infrastructure.Data.Context; public class CommandContext : DbContext { - + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.ApplyConfigurationsFromAssembly(typeof(IEntityTypeConfiguration<>).Assembly); + } } \ No newline at end of file diff --git a/Src/Product.Infrastructure/Data/Context/QueryContext.cs b/Src/Product.Infrastructure/Data/Context/QueryContext.cs index df0d564..d6dc82d 100644 --- a/Src/Product.Infrastructure/Data/Context/QueryContext.cs +++ b/Src/Product.Infrastructure/Data/Context/QueryContext.cs @@ -8,5 +8,8 @@ public QueryContext(DbContextOptions options) : base(options) { } - + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.ApplyConfigurationsFromAssembly(typeof(IEntityTypeConfiguration<>).Assembly); + } } \ No newline at end of file