

The following is the resulting migration. This can be done by using the Sql function of the MigrationBuilder class. Now knowing the process the migration above can be modified to apply SQL directly instead of using Entity Framework Core to generate the SQL.
SQLITE LIMITATIONS HOW TO
The gist of the how to do a rename is to create a new table with the desired schema, copy the data from the original table, drop the old table, and finally rename the new table to match the original name. Searching for how to rename a column in SQLite will turn up a lot of results including this from the official docs and answers like this on StackOverflow. Modify migration to manually rename the column

System.NotSupportedException: SQLite does not support this migration operation (‘RenameColumnOperation’). Protected override void Down(MigrationBuilder migrationBuilder)Īs expected when an attempt to apply the above migration results in the following exception. Protected override void Up(MigrationBuilder migrationBuilder) public partial class RenameContactStateToSubregion : Migration Which produces the following migration class. Add-Migration RenameContactStateToSubregion -c ContactsDbContext With the property name change using the following command in the Package Manager Console to create a new migration. Open the Contact class which can be found in the Models directory and make the following change. Unsupported example with a column renameĪs an example of how to handle a migration that isn’t supported, we are going to rename the State property of the Contact class to Subregion.
SQLITE LIMITATIONS PRO
Thankfully things like ReSpeller (link is to the pro page, but a free version is available in ReSharpers extension manager) help with my spelling issues. These limitations are on the Entity Framework Team’s list of issues as an open enhancement and can be tracked here.Īs long as you are just adding new tables or columns you would never notice the limitation, but if you have spelling problems like I do then the need to rename a column can be important. The official docs on the subject can be found here. SQLite’s ALTER TABLE is limited which in turn limits what Entity Framework Core can do via a migration. The starting point of the code for this post can be found here. The other parts can be found below.Įntity Framework Core Errors Using Add-MigrationĮntity Framework Core with SQLite Scaffolding This is part of what has turned into a series on Entity Framework Core with SQLite.
