You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing dbontext scaffolding on command line for existing DB, throws exception System.ArgumentException. No context or other files are generated.
Command line: dotnet ef dbcontext scaffold "Data Source=sql_srv;Initial Catalog=sql_db;UserID=user;Password=*" Microsoft.EntityFrameworkCore.SqlServer -o Model
There are similar errors reported on #9814, #9188, #9501. However it seems those issues are about exception thrown when using scaffolded model. My case is different - exception is thrown when scaffolding db. No model files are generated, not even output directory "Model" is created.
Database does have columns with datatype nvarchar(max) and nvarchar(4000).
Exception message: System.ArgumentException: 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.
Stack trace: at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerTypeMapper.ValidateTypeName(String storeType)
at Microsoft.EntityFrameworkCore.Storage.Internal.FallbackRelationalTypeMappingSource.FindMappingForStoreTypeName(RelationalTypeMappingInfo& mappingInfo)
at Microsoft.EntityFrameworkCore.Storage.Internal.FallbackRelationalTypeMappingSource.FindMapping(RelationalTypeMappingInfo& mappingInfo)
at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.<FindMappingWithConversion>b__7_0(ValueTuple`3 k)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.FindMappingWithConversion(RelationalTypeMappingInfo& mappingInfo, IReadOnlyList`1 principals)
at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.FindMapping(String storeTypeName)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ScaffoldingTypeMapper.FindMapping(String storeType, Boolean keyOrIndex, Boolean rowVersion)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.GetTypeScaffoldingInfo(DatabaseColumn column)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitColumn(EntityTypeBuilder builder, DatabaseColumn column)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitColumns(EntityTypeBuilder builder, ICollection`1 columns)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTable(ModelBuilder modelBuilder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTables(ModelBuilder modelBuilder, ICollection`1 tables)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Steps to reproduce
Have a sql db sql_db that does have columns with datatype nvarchar(max) and/or nvarchar(4000).
Run on command line: dotnet ef dbcontext scaffold "Data Source=sql_srv;Initial Catalog=sql_db;UserID=user;Password=*" Microsoft.EntityFrameworkCore.SqlServer -o Model
### Further technical details
Entity Framework Core .NET Command-line Tools
2.1.0-preview1-28290 (Version="2.1.0-preview1-final" in .csproj)
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Mac OS
IDE: VS Code
The text was updated successfully, but these errors were encountered:
Thanks for the hint!
Indeed, the issue was in the package Microsoft.EntityFrameworkCore.Tools that was not the latest version.
But it was so logical to suspect "Entity Framework Core .NET Command-line Tools" package that produced exception.
I got model scaffolded using following versions combination:
Doing dbontext scaffolding on command line for existing DB, throws exception System.ArgumentException. No context or other files are generated.
Command line: dotnet ef dbcontext scaffold "Data Source=sql_srv;Initial Catalog=sql_db;UserID=user;Password=*" Microsoft.EntityFrameworkCore.SqlServer -o Model
There are similar errors reported on #9814, #9188, #9501. However it seems those issues are about exception thrown when using scaffolded model. My case is different - exception is thrown when scaffolding db. No model files are generated, not even output directory "Model" is created.
Database does have columns with datatype nvarchar(max) and nvarchar(4000).
Steps to reproduce
The text was updated successfully, but these errors were encountered: