-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Did the naming convention change for HasCheckConstraint in v.6? Is this a breaking change? #27059
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Note for triage: verified that the constraint name is changed to "CK_Records_CHK_Records_Id" in 6.0. Migration with 5.0: using Microsoft.EntityFrameworkCore.Migrations;
namespace FiveOh.Migrations
{
public partial class One : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Records",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1")
},
constraints: table =>
{
table.PrimaryKey("PK_Records", x => x.Id);
table.CheckConstraint("CHK_Records_Id", "[Id] > 10");
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Records");
}
}
} Migration with 6.0: using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Migrations
{
public partial class One : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Records",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1")
},
constraints: table =>
{
table.PrimaryKey("PK_Records", x => x.Id);
table.CheckConstraint("CK_Records_CHK_Records_Id", "[Id] > 10");
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Records");
}
}
} |
This is a known breaking change: https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/breaking-changes#unique-check-constraints |
Ah, thanks. Sorry, I missed that in the docs. I even saw that section but I think my brain shut off because I wasn't doing anything that was related to uniqueness, so it didn't register that that mitigation applied. At the end of the day, in our actual application, we're using |
@davemateer You can set We discussed this again and decided to revert the prefixing change, as it's unexpected and unnecessary. |
Reproduce:
When you generate a migration using
dotnet ef migrations add foo
using .Net 5 and EF Core 5.0.13 (libraries and tool), the migration output includes the following:And the snapshot:
When you change everything to Net 6 and EF Core 6.0.0 (libraries and tool), those change to the following:
Snapshot:
Is this expected, or is this a bug?
The text was updated successfully, but these errors were encountered: