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

浪子不回头ぞ 提交于 2020-01-13 12:10:10

问题


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:


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.



来源:https://stackoverflow.com/questions/30786505/cannot-run-migration-on-entity-framework-7-beta4-in-class-library-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!