I have an old application in .Net Core 3.1 and EF Core 3.1. I have succesfully migrated to .net 8 and EF Core 8. The migrations folder was HUGE, so I reset the migrations, deleting all records in the [__EFMigrationsHistory]
table and deleted the migration folder (the migrations folder is in a separate project.
I succesfully ran the initial migration and EF created the class with all existing tables, columns, indexes, etc. As the Database already exists, I manually added the migrations record to the [__EFMigrationsHistory]
table.
I then had to add a new table. When I ran the Add-Migration, the resulting class is HUGE (should have only contained the necesarry code for the new table). It includes code for (i think) every column in the database, such as the following:
migrationBuilder.AlterColumn<Guid>(
name: "TenantId",
schema: "Common",
table: "XrmOrganization",
type: "uniqueidentifier",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uniqueidentifier",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 300);
migrationBuilder.AlterColumn<int>(
name: "StatusCode",
schema: "Common",
table: "XrmOrganization",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 211);
Any migration I try to add, adds these hundrends (maybe thousands) of line of code, altering the columns. As a remedy, I have manually deleted all these lines of code, but I would like to know the root cause and how to solve this issue, as the migrations file has more than 110 thousand lines.
Any help will be GREATLY appreaciated.