I am new to EF and previously engineered custom ORMs that use TIMESTAMP fields for concurrency and also determining records for synchronization to other databases.
Why does EF (Core) use nvarchar(max) to store what looks like a Guid?
i.e. why does EF do work that the DB could be doing instead?
The obvious thing is at some point (maybe when scaling up to multiple servers/databases) we want to store multiple Guids in there, and/or maybe it is simply because ROWVERSION/TIMESTAMP is not consistently implemented on the DBs targeted by EF?
(on a similar note why is the ID field nvarchar(450)?)
UPDATE:
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
ConcurrencyStamp = table.Column<string>(nullable: true),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
nvarchar(MAX)
for that, and in EF6, it didn't. There could be a configuration problem somewhere, but if this really changed in EF Core, I suspect it's a bug, not a feature. Can you show your class definition and mapping, and the generated table? Aside: "(on a similar note why is the ID field nvarchar(450)?)" -- That's unrelated and probably best to leave out, but note that you should be able to spot the problem in SQL Server's warnings if you simply make itnvarchar(MAX)
outside of EF.