Answer the question
In order to leave comments, you need to log in
How to deal with foreign keys from another database in Entity Framework?
Such a problem.
The database has to store identifiers (uniqueidentifier) units (and not only them) from another database. Example: The Orders table in the Order
database has a DivisionGUID (uniqueidentifier) field, while the DivisionGUIDs themselves and other additional information (names, types, etc.) is in the MasterData database .
The problem is that I don't know how to handle this case with Entity Framework.
Is it possible to somehow solve the problem through views or procedures in the database that return some of the data I need?
Used by: MS SQL 2008, VS 2013, Entity Framework 6
PS In one of my questions on databases, I already raised this topic in the comments, it was suggested to make separate ORM mappings and then manually map them. But the prospect of connecting 5-6 more bases separately to the project is not very encouraging
. By the way, it is interesting to hear the opinion of NHibernate adherents on solving such a problem.
Answer the question
In order to leave comments, you need to log in
Of course, you can write cross-base storers and bind their call to EF. Maybe even get a direct mapping on the entity. But my supervisor and I are of the opinion that cross-base storage is EVIL and must be eradicated by all possible means. If we talk about a specific task, then add access methods at the context level, inside which you can request additional data from another database. If they rarely change - cache.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question