ASP.net vNext和Entity Framework 6

前端之家收集整理的这篇文章主要介绍了ASP.net vNext和Entity Framework 6前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可以在预发布的ASP.net vNext下运行EF6? EF7没有我需要的一些功能,但我想在.NET Core中对我的应用程序进行原型设计.

我收到以下错误

FileLoadException: A strongly-named assembly is required. 
(Exception from HRESULT: 0x80131044) Unknown location

FileLoadException: Could not load file or assembly
'EntityFramework.sqlServer,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089' or one of its dependencies. 
A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

我知道.NET Core不支持名称程序集,但据我所知,我在aspnet50框架下运行服务器而不是aspnetcore50.

我的project.json看起来像这样:

{
    "webroot": "wwwroot","version": "1.0.0-*","dependencies": {
        "EntityFramework": "6.1.1","Microsoft.AspNet.Mvc": "6.0.0-beta3",/* "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta3",*/
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta3","Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta3","Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta3","Microsoft.AspNet.Security.Cookies": "1.0.0-beta3","Microsoft.AspNet.Server.IIS": "1.0.0-beta3","Microsoft.AspNet.Server.WebListener": "1.0.0-beta3","Microsoft.AspNet.StaticFiles": "1.0.0-beta3","Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3","Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta3","Microsoft.Framework.Logging": "1.0.0-beta3","Microsoft.Framework.Logging.Console": "1.0.0-beta3","Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta3","Tricycle.sqlPlatform.EntityFramework": "1.0.0-*"
    },"commands": {
        /* Change the port number when you are self hosting this application */
        "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000","gen": "Microsoft.Framework.CodeGeneration",},"frameworks": {
        "aspnet50": {
            "dependencies": {
                "Tricycle.Studio.ContentManager.Client": "1.0.0-*"
            }
        },//"aspnetcore50": { }
    },"exclude": [
        "wwwroot","node_modules","bower_components"
    ],"bundleExclude": [
        "node_modules","bower_components","**.kproj","**.user","**.vspscc"
    ],"scripts": {
        "postrestore": [ "npm install" ],"prepare": [ "grunt bower:install" ]
    }
}

EF类在单独的项目(Tricycle.Studio.ContentManager.Client)中定义,具有以下project.json:

{
    "version": "1.0.0-*","frameworks": {
        "aspnet50": {
            "dependencies": {
                "System.Data.Common": "1.0.0-beta2","System.Data.sqlClient": "1.0.0-beta2"
            }
        },//"aspnetcore50" : {
        //    "dependencies": {
        //        "System.Runtime": "4.0.20-beta-22523"
        //    }
        //}
    }
}

解决方法

您不能将Microsoft.AspNet.Identity.EntityFramework与EF6一起使用,因为它依赖于EF7.

根据您的project.json文件,运行时将加载EF6和EF7(因为Identity).这种行为是不可预测的.

另外,不要混用beta2和beta3包.这确保了麻烦.

原文链接:https://www.f2er.com/aspnet/248494.html

猜你在找的asp.Net相关文章