Looks like the generated CreateIdentitySchema class needs to be updated to match the current models used for identity so as to not create a migration requiring an AddForeignKey operation which isn't supported by Sqlite.
A simple way to repro the problem:
$ dotnet --version
2.0.0
$ dotnet new mvc --auth Individual
$ dotnet ef migrations add InitialMigration
$ dotnet ef database update
Produces the error:
Applying migration '20170815210528_InitialMigration'.
System.NotSupportedException: SQLite does not support this migration operation ('AddForeignKeyOperation'). For more information, see http://go.microsoft.com/fwlink/?LinkId=723262.
at Microsoft.EntityFrameworkCore.Migrations.SqliteMigrationsSqlGenerator.Generate(AddForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder)
at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.<>c.<.cctor>b__63_1(MigrationsSqlGenerator g, MigrationOperation o, IModel m, MigrationCommandListBuilder b)
at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder)
at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
at Microsoft.EntityFrameworkCore.Migrations.SqliteMigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql(Migration migration)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.<>c__DisplayClass13_2.<GetMigrationCommandLists>b__2()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
SQLite does not support this migration operation ('AddForeignKeyOperation'). For more information, see http://go.microsoft.com/fwlink/?LinkId=723262.
The dotnet db database update will fail because an AddForeignKey call is required to get the schema up to date and the default Sqlite provider doesn't support that operation.
A workaround is to create the migration, then copy the contents of the newly created *.Designer.cs file to the *CreateIdentitySchema.Designer.cs file, and manually resolve the differences in the new db migration *.cs file with the old *CreateIdentitySchemaDesigner.cs, effectively folding the migration up into the initial schema creation. Then delete the db file so a new one is created.
Looks like the generated CreateIdentitySchema class needs to be updated to match the current models used for identity so as to not create a migration requiring an
AddForeignKeyoperation which isn't supported by Sqlite.A simple way to repro the problem:
Produces the error:
The
dotnet db database updatewill fail because anAddForeignKeycall is required to get the schema up to date and the default Sqlite provider doesn't support that operation.A workaround is to create the migration, then copy the contents of the newly created *.Designer.cs file to the *CreateIdentitySchema.Designer.cs file, and manually resolve the differences in the new db migration *.cs file with the old *CreateIdentitySchemaDesigner.cs, effectively folding the migration up into the initial schema creation. Then delete the db file so a new one is created.