title: Multi-Tenant With Code First EF6
body: <p>Our organization has need to have a single database, multi-tenant<br>
  (<strong>by table schema, not by  tenant id</strong>) architecture. </p>
  
  <p>There is a great article here on getting started with this kind of thing here: 
  <a href="http://romiller.com/2011/05/23/ef-4-1-multi-tenant-with-code-first/">http://romiller.com/2011/05/23/ef-4-1-multi-tenant-with-code-first/</a> </p>
  
  <p>In the middle of the article, this is written:</p>
  
  <blockquote>
    <p>You’ll notice (probably with some dismay) we need to write code to
    configure the table schema for each entity. Admittedly there aren’t
    many magic unicorns grazing around this code… in future versions of EF
    we will be able to replace this with a much cleaner custom convention.</p>
  </blockquote>
  
  <p>Our goal is to have the cleanest way possible of having a single context class that we can use to connect to multiple schemas that have the same model.<br>
  (<strong>Note that modelBuilder.HasDefaultSchema doesn't seem sufficient</strong>, because it only applies that the first time EF initializes the context and runs OnModelCreating) </p>
  
  <p>Does the aforementioned cleaner custom convention exist in EF5 or EF6?<br>
  Or is there a cleaner way to handle this somehow?</p>
  
  <p>Note: I also asked this question on the development forum, as it seems to relate more to the direction of EF, but wanted to see if anybody here had alternatives.</p>
  
  <p>Note2: I'm not worried about migrations, we'll handle that seperately.</p>