.NET Core dnx Entity Framework not working correctly

195 views Asked by At

I am using .NET Core to build an application and I am having issues with entity framework. After creating a second migration to update changes made to my models using the "dnx ef migrations add" and the "dnx ef database update" commands, I get errors regarding the attempt to drop foreign key constraints that do not exist. It looks like entity framework is not reviewing the target database before it generates the migrations file.

To try and confirm this I created a brand new database in my development environment and updated my appsettings.json file to target the new database. I then generated another migrations file to check if it would notice the database is blank and create a migrations file to build the schema. It instead created a migrations file with the same issues of trying to drop constraints that do not exist.

Shouldn't entity framework always review the database so it can find the difference between the database schema and model classes?

Thanks

1

There are 1 answers

0
agua from mars On

dnx commands doesn't exit any more ! It was in beta of .net core. Migrate your project to the latest dotnet core version (1.1) and use dotnet commands

To add a migration use command: dotnet ef migration add
To update: dotnet ef update