title: EF Code First Existing database
body: <p>Using EF 4.1 Code first I wanted to stop EF creating database from Models. As I understand if you pass Connectionstring name it will use existing database from that connection string. However if the database does not exists then it will create database will all the tables form the model.</p>
  
  <pre><code>  &lt;connectionStrings&gt;
  &lt;add name="DiaryContext" connectionString="Data Source=.;Initial Catalog=Diary;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>        public MyDiaryContext() : 
          base("name=DiaryContext")
      {
          this.Configuration.LazyLoadingEnabled = true;
          this.Configuration.ProxyCreationEnabled = false;
      }
  </code></pre>
  
  <p>In the above example its behaving as follows:</p>
  
  <p>(1) if database does not exists then it will create the database with all the tables etc.</p>
  
  <p>(2) if the database exists and it has no tables then it will not create new tables</p>
  
  <p>(3) if I add new model the EF code then it will not create the new table in the database.</p>
  
  <p>I am happy with 2 and 3 but in case of (1) if database does not exists then I wanted it to throw the exception instead of creating the db and tables.</p>
  
  <p>In my case the database is being managed by DBA and I dont have total control over this.</p>
  
  <p>Does anyone have any idea how to achive this?</p>
  
  <p>Many thanks,</p>