Entity framework core 1.1.2 migration exception

.net-core c# ef-migrations entity-framework-core

Question

I am getting following strange exceptions.

I already saw following thread discussing about downgrading Microsoft.EntityFrameworkCore.Tools to 1.1.1 which I already did, but still these exceptions are appearing.

System.ArgumentNullException: Value cannot be null.
Parameter name: contentRootPath
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations..ctor(IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String environment, String projectDir, String contentRootPath, String rootNamespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<>c__DisplayClass4_0.<.ctor>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)

Can any body help in this regard.

1
2
2/27/2018 1:59:51 PM

Popular Answer

Just to note in retrospect that I got this error while trying to run a dotnet CLI command. The problem I found was that the CLI environment was defaulting to use the .NET Core 2.0 version of the dotnet and ef commands but I needed to use the .NET Core 1.1 version because that was what the package versions were built against.

I discovered (by running dotnet --info) that there was more than one version of .NET Core SDK installed on the environment and the Path pointed to the latest by default. To use the older version I added a global.json file in the solution root with the specific version number. e.g.

{
  "sdk": {
    "version": "1.1.11"
  }
}

and everything worked.

2
10/15/2018 1:33:05 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow