Skip to content
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

auto migration in ef core #24575

Closed
usapop opened this issue Apr 3, 2021 · 3 comments
Closed

auto migration in ef core #24575

usapop opened this issue Apr 3, 2021 · 3 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@usapop
Copy link

usapop commented Apr 3, 2021

Hi,
I work on wpf project and ef core 2 with sqlite db
I create my class models and use context.Database.EnsureCreated() method, so my database created on runtime.
If I add new column to my model and write context.Database.Migrate() and run my app, I get error no such column 'newColumn'.

@roji
Copy link
Member

roji commented Apr 3, 2021

@usapop you cannot use both EnsureCreated and migrations in the same application. EnsureCreated is generally meant only for prototyping purposes, production applications should use Migrations; after adding a new column, you need to generate a new migration, and then apply that change to your database.

More information is available in the documentation on EnsureCreated and on Migrations.

@roji roji added the closed-no-further-action The issue is closed and no further action is planned. label Apr 3, 2021
@roji
Copy link
Member

roji commented Apr 3, 2021

Note: you may be looking for "automatic migrations", which existed in EF6. This is not supported in EF Core, see #6214 for more information.

@usapop
Copy link
Author

usapop commented Apr 4, 2021

thanks @roji for your answer

@usapop usapop closed this as completed Apr 4, 2021
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants