DDD - 实体跨界上下文的一致性数据库中的不同模式 [英] DDD - Consistency of Entity Across Bounded Context & Different Schemas in Database

查看:25
本文介绍了DDD - 实体跨界上下文的一致性数据库中的不同模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先使用实体​​框架代码实现 DDD.My Domain Model 保持不变,没有任何映射层.

I am implementing DDD with Entity Framework Code First. My Domain Model is persisted as it is without any mapping layer.

我遵循 Tech-Ed 期间建议的方法朱莉·勒曼.每个有界上下文映射到同一数据库中的不同模式.

I am following approach suggested during Tech-Ed by Julie Lerman. Each bounded context maps to different schema within same database.

如果同一个实体说,客户出现在不同的有界上下文中我们如何保持客户实体数据的一致性?

If same entity say, Customer appears across different bounded contexts how do we maintain consistency of data for Customer entity?

推荐答案

只有一个有界上下文将是 您的实体的记录系统.如果您无法仅在其他 BC 中使用 Id,则可以将实体的子集(通常不是所有属性)包含为值对象.

Only a single bounded context will be the system of record for your entity. If you cannot get away with simply an Id in the other BCs then you can include a subset of the entity (usually not all the properties) as a value object.

对 SOR 中实体的任何更改都应作为下游 BC 订阅的消息传递系统中的一个或多个事件发布,以保持其数据最终一致.

Any changes to the entity in the SOR should be published as one or more events in a messaging system that the downstream BCs subscribe to in order to keep their data eventually consistent.

这篇关于DDD - 实体跨界上下文的一致性数据库中的不同模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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