I have started using the Entity Framework to create an application.
MyApp.Users, for instance, has a model that has been tagged internal to the namespace and only exposes functionality to the rest of the system through interfaces. I've established a namespace to house all of my user management code. It's all for the best.
In order to handle certain business logic, I now want to build another namespace. I want it to have a model that is only aware of a different portion of the database structure, however this portion overlaps with the Users table. I see the following problem when attempting to access the second model in the main project:
"An EdmType cannot have more than one mapping to CLR classes."
I believe this shouldn't act in this manner. How does Visual Studio even know that the user table is being referred twice when it is being used by two distinct models in two different namespaces?
Has anybody seen this issue and perhaps discovered a solution that would enable the same table to exist in many models?
Does this reflect an Entity Framework anti-pattern that I should be avoiding, on the other hand?
You must adhere to certain the in-depth procedures described in this blog article in order to utilize types across many models. This functions as well as many other more sophisticated Entity Framework capabilities, but the GUI designer doesn't seem to like it as much. For further guidance on working with bigger models, see also this opening post.
Multiple models are certainly possible, but they cannot cross across. The error message is rather straightforward: there is no practical method to determine which CLR type to map to if they overlap.
You might perhaps attempt to extract the
table into its own third model if it has to be utilized in two other locations.