You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a project and add an entity that contains HierarchyId column and create a migration then the migration contains static type reference to HierarchyId type. Later if you decide that you no longer want to use HierarchyId and remove it from entity and also remove reference to HierarchyId package then compilation does not work for existing migrations because they can no longer find HierarchyId type.
Include your code
Here is my migration that got created automatically after I added HierarchyId to my entity
usingMicrosoft.EntityFrameworkCore.Migrations;usingMicrosoft.SqlServer.Types;//THIS IS PROBLEM LINE
#nullable disable
namespaceApplication.Migrations{/// <inheritdoc />publicpartialclassAddHierarchyIdToMilestone:Migration{/// <inheritdoc />protectedoverridevoidUp(MigrationBuildermigrationBuilder){migrationBuilder.DropColumn(name:"HierarchyLevel",table:"MilestoneTemplates");migrationBuilder.AddColumn<SqlHierarchyId>(//THIS IS PROBLEM LINEname:"HierarchyPath",table:"MilestoneTemplates",type:"hierarchyid",nullable:false,defaultValue:Microsoft.SqlServer.Types.SqlHierarchyId.GetRoot());//THIS IS PROBLEM LINE}/// <inheritdoc />protectedoverridevoidDown(MigrationBuildermigrationBuilder){migrationBuilder.DropColumn(name:"HierarchyPath",table:"MilestoneTemplates");migrationBuilder.AddColumn<int>(name:"HierarchyLevel",table:"MilestoneTemplates",type:"int",nullable:false,defaultValue:0);}}}
When you remove the column and reference to package:
You code no longer works and you have to either keep the package or manually edit the migrations in some way.
I marked lines that statically reference the package with comments.
Include provider and version information
EF Core version: 8.0.8
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8
Operating system: Windows
IDE: Rider
The text was updated successfully, but these errors were encountered:
same thing goes for spatial properties using NetTopologySuite. Migration operations need clr types for the properties so the issue will never go away completely, but we should make it less painful. Migration squashing (#2174) will address that. For now you need to manually modify the migrations or do the squashing "by hand" before removing the package reference.
File a bug
If you have a project and add an entity that contains HierarchyId column and create a migration then the migration contains static type reference to HierarchyId type. Later if you decide that you no longer want to use HierarchyId and remove it from entity and also remove reference to HierarchyId package then compilation does not work for existing migrations because they can no longer find HierarchyId type.
Include your code
Here is my migration that got created automatically after I added HierarchyId to my entity
When you remove the column and reference to package:
You code no longer works and you have to either keep the package or manually edit the migrations in some way.
I marked lines that statically reference the package with comments.
Include provider and version information
EF Core version: 8.0.8
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8
Operating system: Windows
IDE: Rider
The text was updated successfully, but these errors were encountered: