@@ -45,7 +45,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
4545 {
4646
4747 modelBuilder . Entity < ClientRequest > ( ConfigureRequests ) ;
48- modelBuilder . Entity < Address > ( ConfigureAddress ) ;
4948 modelBuilder . Entity < PaymentMethod > ( ConfigurePayment ) ;
5049 modelBuilder . Entity < Order > ( ConfigureOrder ) ;
5150 modelBuilder . Entity < OrderItem > ( ConfigureOrderItems ) ;
@@ -62,19 +61,6 @@ private void ConfigureRequests(EntityTypeBuilder<ClientRequest> requestConfigura
6261 requestConfiguration . Property ( cr => cr . Time ) . IsRequired ( ) ;
6362 }
6463
65- void ConfigureAddress ( EntityTypeBuilder < Address > addressConfiguration )
66- {
67- addressConfiguration . ToTable ( "address" , DEFAULT_SCHEMA ) ;
68-
69- // DDD Pattern comment: Implementing the Address Id as "Shadow property"
70- // becuase the Address is a Value-Object (VO) and an Id (Identity) is not desired for a VO
71- // EF Core just needs the Id so it is capable to store it in a database table
72- // See: https://docs.microsoft.com/en-us/ef/core/modeling/shadow-properties
73- addressConfiguration . Property < int > ( "Id" )
74- . IsRequired ( ) ;
75-
76- addressConfiguration . HasKey ( "Id" ) ;
77- }
7864
7965 void ConfigureBuyer ( EntityTypeBuilder < Buyer > buyerConfiguration )
8066 {
@@ -152,6 +138,8 @@ void ConfigureOrder(EntityTypeBuilder<Order> orderConfiguration)
152138 orderConfiguration . Property ( o => o . Id )
153139 . ForSqlServerUseSequenceHiLo ( "orderseq" , DEFAULT_SCHEMA ) ;
154140
141+ orderConfiguration . OwnsOne ( o => o . Address ) ;
142+
155143 orderConfiguration . Property < DateTime > ( "OrderDate" ) . IsRequired ( ) ;
156144 orderConfiguration . Property < int ? > ( "BuyerId" ) . IsRequired ( false ) ;
157145 orderConfiguration . Property < int > ( "OrderStatusId" ) . IsRequired ( ) ;
0 commit comments