15

I am trying to create a new migration but I get an System.ArgumentNullException saying:

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.<.ct
    or>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.<Execute>b__0()
    at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Value cannot be null.
Parameter name: language
3

6 Answers 6

11

This is issue #11075. The version of your tool doesn't match the version of your runtime. Ensure you've updated every Microsoft.EntityFrameworkCore package to 2.1.0-preview1-final.

Sign up to request clarification or add additional context in comments.

4 Comments

Possibly a different code path for scaffolding vs. migrations? I was hitting the error while doing a db migration. Just saying for me the problem appears to be from a bug introduced in the 2.1.0 Final. Downgrading to 2.0.1 will fixed my issue with migration. Added a detailed note with repro steps in the 11075 issue.
For me the not updated package was the <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.0-preview1-final" /> inside csproj
@animalitomaquina - yup this was it for me as well. Thanks! I need this version for now, because v2.0.2 doesn't support Ambient Transactions.
Thanks, this even was the case for EF6 but helped me as soon as I updated all the projects references to EF to latest version (as of now it is 6.4.4)
6

It's related to the EF Core not EF6, it looks like there is a bug in the 2.1.0.preview1-final version.

  • Check the version you are running with dotnet ef --version
  • Downgrade to the Microsoft.EntityFrameworkCore.Design 2.0.1 version.

1 Comment

Cheers, been scratching my head for a while on this one.
4

If it is EF 6.x.x, then use VS2019.

Ref: https://github.com/dotnet/ef6/issues/1870

1 Comment

No need, just update EF to 6.5.1
0

For EF Core for .NET Core 2.0.1 in VS 2017 Version 15.7.1, I removed DotNetCliToolReference element from my project file.

enter image description here

enter image description here

Comments

0

I think this is a bug.
I'm using EF Core 2.2.4, i'm trying to rollback a migration with:

migrationBuilder.DropIndex(name: "myIndexName");

This was auto-generated for me by EF.
The method signature says name is the only required parameter (there's 2 optional ones after). When i run this i get this:

System.ArgumentNullException: Value cannot be null.
Parameter name: name

but if i add a second parameter for the table name it works:

migrationBuilder.DropIndex(
                name: "myIndexName",
                table: "myTableName");

Comments

0

I encountered the same error in Visual Studio 2022, and updating Entity Framework to version 6.5.1 resolved the issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.