Relationship between different context classes Entity Framework

Posted on

Question :

I have a problem saving an object because it has a relationship in a different context, I would like to know if there is a way to solve this problem.


Answer :

Does not exist.

Not only is the design definition that matters in the Entity Framework: for all relationships and mappings to work correctly, they need to be defined in the same context.

It does not make much sense, in fact, to use objects from different contexts. The context maps a portion of the database. If this data is not accessible by it, and if this data is in a place that is beyond its definition, then that mapping will not be possible.

Reconsider changing your contexts so that all objects can be in a single context, considering that there is dependency between them.


Leave a Reply

Your email address will not be published. Required fields are marked *