Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DDD Database first . How to handle aggregates

I'm trying to learn the concept of DDD. I have made a project which i use the database first approach. In the infrastructure i have added an edmx file witch i have chosen to auto generate the entites. Now in the "Domain" I'm trying to create aggregates.

But here i got some problems. I´m trying to create a aggregate named "User" but User already exists in the entites that the ef autogenerated. Should i rename the aggregate "User" to something else and when getting data from the db map it from db entites to the aggregate.

I'm doing it wrong ? Or shouldn't i autogenerate the entities or is the enties aggregates ?

Plz advise and help.

enter image description here

like image 511
Tan Avatar asked Dec 26 '22 18:12

Tan


1 Answers

If you want to be true to DDD, you should model your domain objects to be independent of your persistence solution. DDD handles persistence through repositories. Don't use the "entities" generated by EF as your domain model; instead design your own model and implement a repository that makes use of EF for persistence.

like image 64
casablanca Avatar answered Dec 29 '22 10:12

casablanca