3
I have a problem saving an object, due to it having relationship in a different context, I wonder if there is a way to solve this problem.
3
I have a problem saving an object, due to it having relationship in a different context, I wonder if there is a way to solve this problem.
6
There is no.
It’s not just the design definition that matters in the Entity Framework: for all relationships and mappings to work properly, they need be defined in the same context.
It doesn’t make much sense, by the way, 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 evades its definition, then this 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.
Browser other questions tagged c# asp.net-mvc entity-framework
You are not signed in. Login or sign up in order to post.
But what if the contexts are pointing to the same bank? For example: in context1 I have the User entity and in context2 I relate the User to other entities...
– Raphael
It won’t work. Just use a context pointing to a bank.
– Leonel Sanches da Silva