ASP.net vNext and Entity Framework 6

8

Is it possible to run EF6 under the pre-release ASP.net vNext? EF7 doesn't have some features I need, but I would like to prototype my application in .NET Core.

I'm getting the following error:

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)

I know that .NET Core doesn't support strongly-named assemblies, but as far as I know I'm running the server under the aspnet50 framework rather than aspnetcore50.

My project.json looks like this:

{
    "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" ]
    }
}

The EF classes are defined in a separate project (Tricycle.Studio.ContentManager.Client) with the following project.json:

{
    "version": "1.0.0-*",
    "dependencies": {
        "EntityFramework": "6.1.1",
    },

    "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"
        //    }
        //}
    }
}
asp.net
entity-framework
asp.net-core
asked on Stack Overflow Mar 17, 2015 by Grokys • edited Mar 17, 2015 by Victor Hurdugaci

1 Answer

9

You cannot use Microsoft.AspNet.Identity.EntityFramework with EF6 because it depends on EF7.

Based on your project.json file, the runtime will load both EF6 and EF7 (because of Identity). The behavior is unpredictable.

Also, do not mix beta2 and beta3 packages. That's guaranteed trouble.

answered on Stack Overflow Mar 17, 2015 by Victor Hurdugaci

User contributions licensed under CC BY-SA 3.0