I have the following API:
builder.Entity
However, SQL Server uses NVARCHAR(MAX) instead of NVARCHAR(4000).
EF Core version: 1.1.2
Database Provider: Microsoft.EntityFrameworkCore.SqlServer 1.1.2
Operating system: Windows 7
IDE: Visual Studio Community 2017
Note that the Migration's Up() method correctly generate the following codes:
migrationBuilder.AddColumn
name: "Message",
table: "EventLogs",
maxLength: 4000,
nullable: false);
Can you explain what do you mean by this?
However, SQL Server uses NVARCHAR(MAX) instead of NVARCHAR(4000).
What I meant is that the datatype is NVARCHAR(MAX) instead of NVARCHAR(4000).
Can you also post output of Script-Migration (dotnet ef migration script if using dotnet cli)
That's a good idea, let me take a look.
Fluent API
Migration

SQL

The above screenshots should describe the problem. Thanks.
https://docs.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql
~nvarchar(4000) should be equivalent of nvarchar(max)~
nvarchar(4001) should be equivalent of nvarchar(max). Error of 1.
"Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000"
In SQL you can DECLARE @_string AS NVARCHAR(4000)
So, I don't think nvarchar(4000) should be equivalent of nvarchar(max) is correct.
Off by one.
This no longer repros on dev. Somebody must have inadvertently fixed it. 馃槈
https://github.com/aspnet/EntityFramework/commit/ae2277ed90c782500df29d2bf735491f316da9a8
Which removed the always setting size for parameters of string type. Instead null are now allowed which makes them nvarchar(max) again.
Most helpful comment
"Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000"
In SQL you can DECLARE @_string AS NVARCHAR(4000)
So, I don't think nvarchar(4000) should be equivalent of nvarchar(max) is correct.