title: EF Core Migrations
body: <p>I am trying to use migrations with a existing database and to create a new one, if not exists.</p>
  
  <p>The EF Core documentations says:</p>
  
  <blockquote>
    <p>If you created the initial migration when the database already exists, the database creation code is generated but it doesn't have to run because the database already matches the data model. When you deploy the app to another environment where the database doesn't exist yet, this code will run to create your database</p>
  </blockquote>
  
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations" rel="nofollow noreferrer" title="From EFCore docs">From EFCore docs</a></p>
  
  <p>I did initial migrations, it creates a up and down methods to create my tables. When I run it to a new database (new database name in connection string) it creates the database and tables as expected.</p>
  
  <p>But if I run it to an existing database (not created by migrations), it fails at the first up method that tries to create a table that already exists, and the migrations stops to run.</p>
  
  <p>Docs says "it doesn't have to run", but first thing migrations is doing is try to create an existing table.</p>
  
  <p>How to prevent migrations to try to create existing tables? There is something like "create if not exists" built in on migrations? Is documentations right? It should works as expected/describe in docs?</p>
  
  <p>If I'm doing it wrong, what is the strategy to work with migrations to run with existing and new on databases?</p>
  
  <p>Dotnet Core version: 1.1.
  EFCore version: 1.1.2.</p>
  
  <p>Thanks in advance.</p>