这是我的数据库表
CREATE TABLE `File` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` varchar(50) DEFAULT NULL,
`description` varchar(50) DEFAULT NULL,
`extension` varchar(50) DEFAULT NULL,
`path` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
)
我用来生成模型的命令:
Scaffold-DbContext "server=..;user id=..;password=..;database=..;sslmode=none;" MySql.Data.EntityFrameworkCore -OutputDir Models -f
我得到的错误:
System.ArgumentException: The string argument 'sql' cannot be empty.
at Microsoft.EntityFrameworkCore.Utilities.Check.NullButNotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.RelationalPropertyBuilderExtensions.HasComputedColumnSql(PropertyBuilder propertyBuilder, String sql)
at Microsoft.EntityFrameworkCore.Scaffolding.RelationalScaffoldingModelFactory.VisitColumn(EntityTypeBuilder builder, ColumnModel column)
at Microsoft.EntityFrameworkCore.Scaffolding.RelationalScaffoldingModelFactory.VisitColumns(EntityTypeBuilder builder, ICollection`1 columns)
at Microsoft.EntityFrameworkCore.Scaffolding.RelationalScaffoldingModelFactory.VisitTable(ModelBuilder modelBuilder, TableModel table)
at Microsoft.EntityFrameworkCore.Scaffolding.RelationalScaffoldingModelFactory.VisitTables(ModelBuilder modelBuilder, ICollection`1 tables)
at Microsoft.EntityFrameworkCore.Scaffolding.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
at Microsoft.EntityFrameworkCore.Scaffolding.RelationalScaffoldingModelFactory.CreateFromDatabaseModel(DatabaseModel databaseModel)
at MySql.Data.EntityFrameworkCore.Design.Internal.MySQLScaffoldingModelFactory.Create(String connectionString, TableSelectionSet tableSelectionSet)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator.GetMetadataModel(ReverseEngineeringConfiguration configuration)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator.GenerateAsync(ReverseEngineeringConfiguration configuration, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContextAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<ScaffoldContextImpl>d__22.MoveNext()
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass4_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The string argument 'sql' cannot be empty.
它说sql参数不能为空,但我不会使用&#39; sql&#39;任何地方。什么似乎是问题?
答案 0 :(得分:1)
我通过使用Pomelo.EntityFrameworkCore.MySql代替MySql.Data.EntityFrameworkCore“修复”了这个问题