I'm trying to upgrade my app to ASP.NET Core 2, with EF Core 2 (and SQLite), in other words netcoreapp2.0
. I followed the upgrade guide.
I also recreated migrations, and noticed the new ones are quite different from the ones I remember from 1.1 (different commands sent to the db, different syntax, etc). But my model is the same, and after generating migrations, everything compiles properly.
BUT, when I try to create the db programmatically using context.Database.Migrate();
, or manually on the CLI using dotnet ef database update
, I get
System.NotSupportedException: SQLite does not support this migration operation ('AddForeignKeyOperation'). For more information, see http://go.microsoft.com/fwlink/?LinkId=723262.
However, I don't use the AddForeignKeyOperation
command anywhere in my solution (I searched for it). I searched my migration files, and they don't use that command.
I'm sure it's something basic, but I can't track it down. What could it be?
Turns out the problem was not deleting all migrations.
I had the "initial" migration, then migration1, migration2, etc. The initial migration is from the template, so it had Identity/roles/users/etc. So I left that one alone and deleted/recreated the other ones only (i.e. the ones with my domain model).
Well it turns out that when I deleted ALL migrations, and recreated them, I stopped getting that error.
That error is confusing and poorly worded, and has nothing to do with the problem. Hope this helps someone else.