title: How to handle one class used in multiple db contexts for one database in EF code first?
body: <p>I am trying to make some module class library APIs that use EF in my repository layer. For any of that to work I need a dbcontext class in each class library. But what happens when I need one class to be referenced in each module? Take for example I have a users module whose db contexts includes:</p>
  
  <ul>
  <li>Users </li>
  <li>Groups </li>
  <li>Roles</li>
  </ul>
  
  <p>Then I have a locations module that includes:</p>
  
  <ul>
  <li>Buildings</li>
  <li>Locations</li>
  <li>Rooms</li>
  </ul>
  
  <p>Then say a third module for Equipment which has:</p>
  
  <ul>
  <li>Equipment</li>
  <li>Equipment Types</li>
  <li>Work Orders</li>
  </ul>
  
  <p>The latter two still need references to users, which is pretty much integral to every module. But I can't add two separate user classes to two contexts pointing to the same db, it's possible they could become out of sync then. So the obvious solution there is just have the latter 2 modules require the user module, and any class in those modules that needs the user just references the userID. This would break normalization though since it wouldn't be a foreign key so I am not sure how good that idea is.</p>
  
  <p>Another possibility that popped into my head was having each module's dbcontext use an interface, and allow the person using the module to declare their own dbcontext and implement all those members, but I'm not sure that will work either.</p>
  
  <p>I basically just want to make a collection of class library modules that define a common set of classes and API calls available to other programmers, while using EF as the base with the intent that this would all be stored in one DB. But I'm not quite sure how to accomplish that with how DbContexts work. What happens when you have multiple modules requiring the same object?</p>