-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Running dnx ef update database creates empty db #3981
Comments
I'm having the same issue. |
I have the same issue, too. |
It is not quite the samme issue. I have a custom startup.cs file in my migration project, that refrences the data project. This actually are creating the migration files as expected, but for some reason it does not update my database. Just creates a empty db. |
Did you do on EmptyDB.Migrations project folder with the command? dnx ef migrations add Init --targetProject EmptyDB.Data |
As i write above in first post and second post, and you can see in the repository provided, I dont have a problem generating the migration. The issue occurs when i try to update the database, list migrations or generate sql script. It cannot find any of my MIgrations previously created. I run the command from EmptyDB.Migration project, but that should(if i am not misunderstanding some thing) work since i have reference to data project and i have the startup file created in that project. |
The migration script should be generated in the project which has DbContext, EmptyDB.Data, not in EmptyDB.Migrations or EmptyDB. Without --targetProject option, migration scripts are generated in the project in which dnx runs, and it will generate empty db. |
But shouldn't the question be, why you have to put your migrations in the same project as the DbContext? If this is the expected behaviour I would at least expect an Error/Info message when I generate migrations in a project with no DbContext, or when I try to run a DB update with Migrations and a DbContext in separate projects. |
Yes that's my point as well. If its by design that's fair enough, but i would still be curious to why its that way. I also agree that even if it is by design it should shown an error/info message. |
We know we need to improve this and that work is tracked by #3879. For the moment, did you specify |
Also opened #4008 as a helpful enhancement that came up while we were discussing this. |
Yes tested with |
Thanks for confirming. Chaining a call to |
In my repo i have the migration files in EmptyDB.Migrations, so i ùsed |
No, I think everything is tracked by other issues. |
I currently have an issue where i create a migration with dnx ef migrations add init. It creates the migrations as expected, but when i try to run dnx ef database update i just creates an empty database with the ef migrations history table.
I have reproduced this issue in this repository.
I am running db update from EmptyDB.Migrations project. Not sure if my way of doing it is wrong, but i guess it should give me some kind of error of its wrong.
The text was updated successfully, but these errors were encountered: