添加迁移值不能为空。 参数名称:语言

我正在尝试创建一个新的迁移,但我得到一个System.ArgumentNullException说:

System.ArgumentNullException: Value cannot be null. Parameter name: language at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations..ctor (IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String projectDir, String rootNamespace, String language) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.c__DisplayClass4_0.b__4() at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.c__DisplayClass3_0`1.b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) Value cannot be null. Parameter name: language 

它与EF Core而不是EF6有关,看起来2.1.0.preview1-final版本中存在一个错误。

  • 使用dotnet ef –version检查您运行的版本
  • 降级到Microsoft.EntityFrameworkCore.Design 2.0.1版本。

这是问题#11075 。 您的工具版本与运行时版本不匹配。 确保已将每个Microsoft.EntityFrameworkCore包更新到2.1.0-preview1-final。

对于VS 2017版本15.7.1中的EF Core for .NET Core 2.0.1,我从项目文件中删除了DotNetCliToolReference元素。

在此处输入图像描述

在此处输入图像描述