简体   繁体   English

EF Core 5.0.5 Add-Migration 字符串参数“名称”不能为空

[英]EF Core 5.0.5 Add-Migration The string argument 'name' cannot be empty

I am having an issue in regards with Add-Migration and gave me an error The string argument 'name' cannot be empty.我在Add-Migration方面遇到问题,并给了我一个错误The string argument 'name' cannot be empty. . . I tried executing this command like this: Add-Migration Update_Add_User .我尝试像这样执行此命令: Add-Migration Update_Add_User

Here is the error:这是错误:

Build started... Build succeeded.构建开始...构建成功。 System.ArgumentException: The string argument 'name' cannot be empty. System.ArgumentException:字符串参数“名称”不能为空。 at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName) at Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper.Identifier(String name, ICollection 1 scope) at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(CreateTableOperation operation, IndentedStringBuilder builder) at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(String builderName, IReadOnlyList 1 operations, IndentedStringBuilder builder) at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGenerator.GenerateMigration(String migrationNamespace, String migrationName, IReadOnlyList 1 upOperations, IReadOnlyList 1 downOperations) at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String n在 Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName) 在 Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper.Identifier(String name, ICollection 1 scope) at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(CreateTableOperation operation, IndentedStringBuilder builder) at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(String builderName, IReadOnlyList Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGenerator.GenerateMigration(String migrationNamespace, String migrationName, IReadOnlyList 1 upOperations, IReadOnlyList 1 scope) at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(CreateTableOperation operation, IndentedStringBuilder builder) at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(String builderName, IReadOnlyList 1 operations, IndentedStringBuilder builder) 1 upOperations, IReadOnlyList 1 downOperations) 在 Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String n ame, String outputDir, String contextType, String namespace) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) The string argument 'name' cannot be empty. ame, String outputDir, String contextType, String namespace) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.< .ctor>b__0() 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0() 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) 字符串参数“名称”不能空的。

can anyone tell me how to fix this?谁能告诉我如何解决这个问题?

Update: Nuget Packages更新:Nuget 包

Microsoft.EntityFrameworkCore 5.0.5 Microsoft.EntityFrameworkCore.SqlServer 5.0.5 Microsoft.EntityFrameworkCore.Design 5.0.5 Microsoft.EntityFrameworkCore 5.0.5 Microsoft.EntityFrameworkCore.SqlServer 5.0.5 Microsoft.EntityFrameworkCore.Design 5.0.5

Make sure you add the nuget package Microsoft.EntityFrameworkCore.Tools else you won't be able to run EF commands on the Package Manager Console.确保添加 nuget package Microsoft.EntityFrameworkCore.Tools否则您将无法在 Package 管理器控制台上运行 EF 命令。

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 5.0.5

Do you get the same error if you used dotnet ef add-migration nameOfMigration ?如果您使用dotnet ef add-migration nameOfMigration会出现同样的错误吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM