1

We use DDD practices in our current project. Our issue is we have a lot of bounded contexts and each context is a layered architecture that contains its persistence layer. The problem is that for example in a bounded context we need to reference data from other bounded context for example the IdentityAccess context is the context that is responsible for managing the user so, it contains UserModel but we need to reference the user in another bounded context so, we create a SubscriberUserModel that contains subset info from the user model in that bounded context. We have a Migration project that contains all of the models from all of our bounded contexts that is used to manage the migrations and our database but we face an issue. We can't have more that one entity that is refer to the same table My Question is to how handle this issue in a smart way This is the EF Exception when we try to generate a new migration

enter image description here

1 Answer 1

4

The answer is don't!

From DDD perspective you're doing it wrong. Bounded Contexts shouldn't be bound with relations like in your case, but independent tables that have nothing to do with a table in another context.

What you should do is to create a User in context A that has the neccessary properties to exist inside context A. The information about user from context A should be transferred from context B, via event, queue, web service, a trigger of some sort etc., but they shouldn't be bounded with a relation.

That way you may be copying unnecessary data from context B that have nothing to do with entity and business process in context A. Although they bare the same name (User), their role and logic in their contexts are completely different. Don't let that fool you!

A good video on the subject is by Julie Lerman on Pluralsight (not an ad :)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.