SQLite :Replace Many schema change operations are not supported by the EF Core SQLite provider.
Replace Many schema change operations are not supported by the EF Core SQLite provider. with include
[!INCLUDE[](~/includes/RP-mvc-shared/sqlite-warn.md)]
See also #11335
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 01013ef6-c55c-ff58-571c-ddc4435993af
- Version Independent ID: 24699fe5-9744-1796-0798-f7b211ec0f2f
- Content: Add a new field to a Razor Page in ASP.NET Core
- Content Source: aspnetcore/tutorials/razor-pages/new-field.md
- Product: aspnet-core
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
Actually the only workaround to continue with the tutorial was to add the new fields to the initial migration and drop the database. Comments would be needed to properly work on this.
Actually the only workaround to continue with the tutorial was to add the new fields to the initial migration and drop the database.
I was able to continue by deleting the Database file and the entire Migrations folder, and then recreating the initial migration:
> dotnet ef migrations add InitialCreate
> dotnet ef database update
...which accomplished the same thing.
As a way to explorer the options under dotnet ef migrations, instead of deleting the migrations folder, I ran
dotnet ef migrations remove
and then continue with the steps used to add/create the database under Add Model
dotnet ef migrations add InitialCreate
dotnet ef database update
@celsoglima thanks for your comment
dotnet ef migrations remove
is the right approach. @tdykstra is this the approach we want to use on the next update?
is this the approach we want to use on the next update?
Yes, it looks better than deleting the Migrations folder.
Don't forget that you cannot remove migrations if you have database in production. You always have to migrate from the old schema to the new schema. If something is not supported out of the box (in Entity Framework or database) you have to write migration manually in raw SQL - there is no other choice.
To get around the SQLite limitations, first save all project files containing the new Model. Then:
- Delete MvcMovie.db
- Delete all files under the Migrations subfolder.
- Run "dotnet ef migrations add Initial"
- Run "dotnet ef database update"
- Run the project.
@juliuso a better approach
Replace 1 with
dotnet ef database drop
I did try running 'dotnet ef migrations remove' twice since there were two existing migrations, but those attempts failed. Perhaps it's better to use postgres or MySQL in future tutorials to sidestep this entirely.
@tdykstra maybe we need a backup approach that includes manual delete of db.
@Rick-Anderson @juliuso I'm addressing a similar situation while adding SQLite to the 3.0 version of the EF RP series. Essentially recommending the @juliuso sequence with the suggested change to step 1, for dealing with data model changes in the tutorial that SQLite can't handle. Some it can handle, like new columns. In a real app you'd be writing table rebuild SQL for migrations that aren't automated. SQLite is a popular cross-platform RDBMS and I don't think the migrations issues are serious enough to abandon it for cross-platform tutorials. Showing how to do manual table rebuilds is out of scope of these tutorials now, but it may be worth adding in the future.