I have a model like this:
public class Student
{
public int Id { get; set; }
public string UniqueCode { get; set; }
}
Configuration:
modelBuilder.Entity<Student>()
.HasKey(x => x.Id);
modelBuilder.Entity<Student>()
.HasIndex(x => x.UniqueCode)
.IsUnique();
And generated migrations:
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UniqueCode = table.Column<string>(type: "nvarchar(450)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Students_UniqueCode",
table: "Students",
column: "UniqueCode",
unique: true,
filter: "[UniqueCode] IS NOT NULL");
EF set the string property to nvarchar(450), I know maybe EF is wise enough to know that SQL will not allow creating an index on nvarchar(max) but why 450 chars? why not at least give a warning during generating migrations?
Include provider and version information
EF Core version: EF 7.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: Windows
I have a model like this:
Configuration:
And generated migrations:
EF set the string property to
nvarchar(450), I know maybe EF is wise enough to know that SQL will not allow creating an index onnvarchar(max)but why 450 chars? why not at least give a warning during generating migrations?Include provider and version information
EF Core version: EF 7.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: Windows