em> 。Instead of being promiscuous (serving everyones' needs), it would give the context clear intention. 仅当需要更改汇总时,上下文才需要更改。它随着聚合而发展。在更大的上下文中,系统的许多部分可能取决于上下文的一部分。单个更改可能会危害很多。The context will only ever need to change when the aggregate needs to change. It evolves with the aggregate. With larger contexts, many parts of the system could depend on one part of the context. A single change could jeopardise a lot.仅聚合所需的表,字段和关系将需要在上下文中存在。通常,在处理更大的上下文时,您不必担心给定表上的大多数关系或字段。Only the tables, fields and relationships needed by the aggregate will need to exist in the context. Often when dealing with a larger context, you aren't bothered with most of the relations or fields on a given table.这种方法有缺点。即: 尽管它们的建模方式可能有所不同(取决于使用情况),但某些数据库表和关系可能需要存在在多种情况下。Although they would likely be modeled differently (depending on their use), certain database tables and relationships may need to exist in multiple contexts.如果使用,则代码优先迁移将非常棘手。If used, code-first migrations would be tricky.这可能是 有人可以对此方法提供进一步的见解吗?也许我忽略了什么?Can anyone provide further any insight on this approach? Is there perhaps something which I have overlooked? 编辑:请注意,我们不在以下位置使用EF数据实体我们的域名。我们的存储库从这些数据实体实例化并合并了一个更丰富的域模型。Note that we are not using the EF data entities in our domain. Our repositories instantiate and hydrate from these data entities a richer domain model.推荐答案我不认为多重聚合上下文是一种问题,尤其是如果您遵循严格的聚合分隔-没有引用聚合以外的实体,则仅按键进行根到根的松散引用。I don't see multiple-aggregate Contexts as a problem, especially if you follow strict aggregate separation -- no reference to entities outside aggregate, only root-to-root loose references by key.如果确定可以肯定,这就是为什么您会想要原子DbContexts的性能瓶颈。On the other hand, I could see why you would want atomic DbContexts if you know for sure it's a performance bottleneck.不过,一件事情是:EF上下文不必精确地映射到有界层上下文。如果这样做,并且您尝试在两侧尽可能地缩小上下文,则可能会对域层IMO造成损害。 BC领域可能会失去其连贯性,并且在此过程中可能会丢失重要的普遍存在的语言概念和细分的语义。One thing though : EF contexts don't have to map exactly to Domain layer Bounded Contexts. If they do and you try to shrink your contexts as much as possible on both sides, it could cause damage in the Domain layer IMO. The domain BC's could lose their coherence and the semantics of important ubiquitous language notions and subdivisions could be lost in the process. 这篇关于聚合,事务一致性和实体框架DbContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 04:57