-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArgumentException in runtime with nvarchar type #9656
Comments
@JuanIrigoyen The exception message says, "Data type 'nvarchar' is not supported in this form. Either specify the length explicitly in the type name, for example as 'nvarchar(16)', or remove the data type and use APIs such as HasMaxLength to allow EF choose the data type." Are you still getting this exception after following these instructions, or is there something not clear about what the message says? |
This error is about a sample of my model for test the new 2.0 version. I have generated a new model using Scaffold and test it with a console program. I the previous version this not had errors. I don't understand because a need to change my model before using Scaffold-DbContext. Why in this version nvarchar is not support? |
@JuanIrigoyen The scaffolding issue is tracked by #9188. As described in that issue, scaffolding is generating "nvarchar" column types when it shouldn't be. The workaround (until we ship a fix and assuming you don't want to use pre-release nightly builds) is to remove/replace these in the generated code--usually this can be done with a pretty simple find/replace. So for example, if you have "nvarchar" types something like this: entity.Property(e => e.Notes)
.HasColumnType("nvarchar"); because scaffolding has created this for "nvarchar(4000)" types, then change in the generated code either like this: entity.Property(e => e.Notes)
.HasColumnType("nvarchar(4000)"); or like this: entity.Property(e => e.Notes)
.HasMaxLength(4000); Note that the runtime behavior here has not changed between 1.1 and 2.0. It was not valid to do |
I receive an argument exception in runtime 'Data type 'nvarchar' is not supported in this form.' when run a query in EF 2.0
Note that in this case, the query don´t refer to nvarchar fields because in the entity 'UsuariosDepartamentos' don´t have fields nvarchar. I suppose that is for the relation with 'Usuarios' entity that have nvarchar fields.
Steps to reproduce
Write a query that use a entity with nvarchar fields
Further technical details
EF Core version: 2.0
Database Provider: Sql Server 2016
Operating system: Windows 10 Pro
IDE: Visual Studio 2017 15.3.3
The text was updated successfully, but these errors were encountered: