From 2f1f1cd61671db902b411064b64266832b1e0722 Mon Sep 17 00:00:00 2001 From: Eduard Tomas Date: Thu, 13 Jul 2017 12:34:19 +0200 Subject: [PATCH] Address as EF Value object --- .../Ordering.Infrastructure/OrderingContext.cs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs index 0c69fe566..42110a7f7 100644 --- a/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs +++ b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs @@ -45,7 +45,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure { modelBuilder.Entity(ConfigureRequests); - modelBuilder.Entity
(ConfigureAddress); modelBuilder.Entity(ConfigurePayment); modelBuilder.Entity(ConfigureOrder); modelBuilder.Entity(ConfigureOrderItems); @@ -62,19 +61,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure requestConfiguration.Property(cr => cr.Time).IsRequired(); } - void ConfigureAddress(EntityTypeBuilder
addressConfiguration) - { - addressConfiguration.ToTable("address", DEFAULT_SCHEMA); - - // DDD Pattern comment: Implementing the Address Id as "Shadow property" - // becuase the Address is a Value-Object (VO) and an Id (Identity) is not desired for a VO - // EF Core just needs the Id so it is capable to store it in a database table - // See: https://docs.microsoft.com/en-us/ef/core/modeling/shadow-properties - addressConfiguration.Property("Id") - .IsRequired(); - - addressConfiguration.HasKey("Id"); - } void ConfigureBuyer(EntityTypeBuilder buyerConfiguration) { @@ -152,6 +138,8 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure orderConfiguration.Property(o => o.Id) .ForSqlServerUseSequenceHiLo("orderseq", DEFAULT_SCHEMA); + orderConfiguration.OwnsOne(o => o.Address); + orderConfiguration.Property("OrderDate").IsRequired(); orderConfiguration.Property("BuyerId").IsRequired(false); orderConfiguration.Property("OrderStatusId").IsRequired();