title: Entity Framework set database schema depending on deployment environment
body: <p>The application I develop is deployed to severeal environments (development, test, staging, production).</p>
  
  <p>While developing I created the entity model from the existing development-database. Everything works fine, but as I wanted to put the application onto the test-environment, I realized the following problem:</p>
  
  <p>The structure of the database is identical in all environments, but the database schema changes from environment to environment. For example there's a <code>Customers</code> table in every database. On my local dev machine it has the schema dbo (<code>[dbo].[Customers]</code>), but in the test environment the schema is test (<code>[test].[Customers]</code>), whilst the schema is stag in the staging environment (<code>[stag].[Customers]</code>) and so forth.</p>
  
  <p>So when I deploy the application in the test environment, it gets no data from the database, because the entity framework expects the data to be found in <code>[dbo].[Customers]</code> but there is no such table, there is just a <code>[test].[Customers]</code>.</p>
  
  <p>I know, that I can define a <a href="https://stackoverflow.com/questions/9341922/change-entity-framework-database-schema-map-after-using-code-first">schema other than dbo</a>, but this doesn't help me, because I need a different schema depending on the deployment environment.</p>
  
  <p>Any suggestions?
  Somehow I think I'll be ending up, asking my DB admin to change the schema to dbo in every database in each environment...</p>