title: Entity Framework - Cannot create multiple DbContexts that reference the same table. - Workaround
body: <p>As per the title, the scenario is: one c-sharp project, with two folders, each containing two EDMX contexts...</p>
  
  <blockquote>
    <p>Myproj\NSOne\ModelOne.edmx, Myproj\NSTwo\ModelTwo.edmx;</p>
  </blockquote>
  
  <p>Generally this works well, until you share the same table across both contexts. No problem at design time, Entity Classes get generated under different namespaces, it's only at runtime that you get the following error:</p>
  
  <blockquote>
    <p>Schema specified is not valid. Errors: The mapping of CLR type to EDM
    type is ambiguous because multiple CLR types match the EDM type
    'TB_MyTable'. Previously found CLR type 'Namespace.NSOne.TB_MyTable',
    newly found CLR type 'Namespace.NSTwo.CIXModel.TB_MyTable'.</p>
  </blockquote>
  
  <p>While searching for answers, I've come across a Github issue that pretty much say "it is too hard / not trivial" we won't fix.
  <a href="https://github.com/aspnet/EntityFramework6/issues/362" rel="nofollow noreferrer">https://github.com/aspnet/EntityFramework6/issues/362</a></p>
  
  <p>However, a workaround is to edit the EDMX file, as mentioned in that github issue.</p>
  
  <pre><code>&lt;ConceptualModels&gt;
      &lt;Schema Namespace="ConsoleApplication33" 
          Alias="Self" 
          annotation:UseStrongSpatialTypes="false"
          xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" 
          xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" 
          xmlns="http://schemas.microsoft.com/ado/2009/11/edm"&gt;
      &lt;EntityType Name="Person" 
          customannotation:ClrType="MyApp.Person, MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&gt;
          &lt;Key&gt;
          &lt;PropertyRef Name="Id" /&gt;
          &lt;/Key&gt;
          &lt;Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" /&gt;
          &lt;Property Name="Name" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" /&gt;
      &lt;/EntityType&gt;
      &lt;EntityContainer Name="Town" customannotation:UseClrTypes="true"&gt;
          &lt;EntitySet Name="People" EntityType="Self.Person" /&gt;
      &lt;/EntityContainer&gt;
      &lt;/Schema&gt;
  &lt;/ConceptualModels&gt;
  </code></pre>
  
  <p>My problem / question is, in my project the above xml fragment with "ConceptualModels" is nowhere to be found ?!</p>
  
  <p>Where do I even begin to look ? Within my edmx files (thru visual studio), I can only see, for example,</p>
  
  <ul>
  <li>ModelOne.edmx    
  
  <ul>
  <li>ModelOne.Context.tt      </li>
  <li>ModelOne.Designer.csharp </li>
  <li>ModelOne.edmx.diagram</li>
  <li>ModelOne.tt</li>
  </ul></li>
  </ul>
  
  <p>EntityFramework.dll, EntityFramework.SqlServer.dll versions are:</p>
  
  <blockquote>
    <p>File version: 6.2.61023.0 
    Product version: 6.2.0-61023</p>
  </blockquote>