Cannot run migration on Entity Framework 7 beta4 in class library package

2.2k views Asked by At

I am unable to execute migration command in a class library package. My dnvm version is (from global.json):

"sdk": {
        "version": "1.0.0-beta5-12021"
    }

I'm importing this in my project JSON.

"dependencies": {
   "EntityFramework.Commands": "7.0.0-beta4",
   "EntityFramework.SqlServer": "7.0.0-beta4",
   "Microsoft.CSharp": "4.0.0-beta-22816",
   "System.Collections": "4.0.10-beta-22816",
   "System.Linq": "4.0.0-beta-22816",
   "System.Threading": "4.0.10-beta-22816",
   "EntityFramework.Core": "7.0.0-beta4"
},
"commands": {
   "ef": "EntityFramework.Commands"
}

My OnConfiguring method in my DbContext inherited class is

protected override void OnConfiguring(DbContextOptionsBuilder    optionsBuilder)
    {
        optionsBuilder.UseSqlServer(@"Server=(localdb)\ProjectsV12;Database=Ef7;Trusted_Connection=True;");
    }

But when I run dnx . ef migration add initial I get the following output:

System.ArgumentNullException: Value cannot be null.
Parameter name: appEnv
   at Microsoft.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)
   at Microsoft.Data.Entity.Commands.Program..ctor(IServiceProvider serviceProvider, IApplicationEnvironment appEnv, ILibraryManager libraryManager)

I've been trying to figuring this out for a while now, so all help is appreciated. Thanks.

1

There are 1 answers

1
Martin On BEST ANSWER

I just found a way to work around this. This seem to be happening with the latest version of the coreclr. Instead of calling

dnvm install -r coreclr latest

I called the following to switch from the latest version to beta4.

dnvm use 1.0.0-beta4 -r coreclr

When I call "dnx . ef", the Entity Framework migration tool starts.