New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations doesn't work with Beta 7 (Only Initial migration is found) #3160

timvanderweijde opened this Issue Sep 17, 2015 · 3 comments


None yet
2 participants
Copy link

timvanderweijde commented Sep 17, 2015


I created a migration with
dnx ef migrations add Initial
dnx ef database update

After that I made some changes to the model and I added a new Migration Second
dnx ef migrations add Second.

Now when I try to update the database I get an error.
I tried:
dnx ef database update
dnx ef database update Second
dnx ef database update _Second

The error says the table is already created. This because the update tried to load the "Initial" migration again.

What can I do?

Cheers, Tim


This comment has been minimized.

Copy link

rowanmiller commented Sep 18, 2015

@timvanderweijde can you provide some detailed steps for us to reproduce this? We are not able to get the same result. If you can provide initial code, the change you make, etc.


This comment has been minimized.

Copy link

timvanderweijde commented Sep 19, 2015


I started to create a demo project and I noticed a difference (and the reason why I got the error).

I also used another tutorial:

In there there a line:
if (context.Database.AsRelational().Exists())

But this line doesn't work with beta7 anymore. (the tutorial is behind)

I replaced this with this line:

So, before Migration I already created the database by running the application. And I quess if the database doesn;t have the table __MigrationHistory it will try to install the Initial migration script. This will always and up with an error related the table already exists. It would be nice to have a little bit more information of missing a MigrationTable e.g.

And how can I do "if (context.Database.AsRelational().Exists())" with beta 7?

Regards, Tim


This comment has been minimized.

Copy link

rowanmiller commented Sep 30, 2015

Hey @timvanderweijde,

Ok that explains it, EnsureCreated totally bypasses migrations and just creates the schema for you, you can't mix this with migrations. EnsureCreated is designed for testing or rapid prototyping where you are ok with dropping and re-creating the database each time. If you are using migrations and want to have them automatically applied on app start, then you can use context.Database.Migrate() instead.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment