Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use the same table in multiple models?
    primarykey
    data
    text
    <p>I'm working with Entity Framework 4.1 in an MVC3 Web Application. I am tasked with re-writing a legacy application with a database w/ approximately 200+ tables, already in place with data, thus taking the Database first approach with EF. </p> <p>I understand that it's bad practice to create one giant edmx model for the entire app, but after hours of research, I can't get a clear direction on how to move forward because I can't figure out how to re-use common tables in more than one model. But I'd like to break up my models into smaller, managable contexts. </p> <p>When I place a common table (such as Users) in two models, the project throws a compilation error in the form of: </p> <blockquote> <p>The type 'Project.Models.EntityX' already contains a definition for 'EntityX_PropertyY'</p> </blockquote> <p>The closest I've found to a workaround was here: <a href="http://connect.microsoft.com/VisualStudio/feedback/details/366721/entity-framework-the-type-xxx-already-contains-a-definition-for-x" rel="nofollow">http://connect.microsoft.com/VisualStudio/feedback/details/366721/entity-framework-the-type-xxx-already-contains-a-definition-for-x</a></p> <blockquote> <p>Posted by Microsoft on 9/17/2008 at 5:18 PM </p> <p>This issue is by design. The work-around is to either put the models in a different folder (for C# &amp; ASP.NET projects), or to set the custom tool namespace (for C# &amp; VB projects). </p> </blockquote> <p>This was back in '08. I couldn't get either option to work, and I'm wondering if there is a better way to go about architecting the project so that I am able to use the same table in more than one model?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload