DDD数据库首先。如何处理聚合 [英] DDD Database first . How to handle aggregates

查看:168
本文介绍了DDD数据库首先。如何处理聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习DDD的概念。我已经做了一个项目,我使用数据库的第一个方法。
在基础架构中,我添加了一个edmx文件,我选择自动生成这些文件。现在在域我试图创建汇总。



但是这里我有一些问题。我试图创建一个名为User的聚合,但用户已经存在于ef自动生成的内容中。我应该将聚合用户重命名为别的东西,当从数据库映射获取数据时,从db获取数据到聚合。



我做错了?或者我不应该自动生成实体,还是自动生成实体?或者是内容聚合?



Plz建议和帮助。



img src =https://i.stack.imgur.com/DXEz0.pngalt =enter image description here>

解决方案

如果你想要对DDD是真实的,你应该建立你的域对象来独立于你的持久性解决方案。 DDD通过存储库处理持久性。不要使用EF生成的实体作为域模型;而是设计自己的模型,并实现使用EF进行持久化的存储库。


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.

解决方案

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.

这篇关于DDD数据库首先。如何处理聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆