ASP.NET 5 Web项目和Entity Framework在单独的项目 [英] ASP.NET 5 Web project and Entity Framework in separate projects
问题描述
从哪里开始......这让我一整天。
Where to begin... This has had me all day.
我已经更新我的项目中使用新的ASP.NET 5空preVIEW模板。
I have updated my projects to use the new ASP.NET 5 Empty Preview Template.
我设法让我的所有项目的建设,但是当我跑我的网站,我得到这个错误
I have managed to get all my projects building, but when i run my website, i get this error
目前的运行目标框架不兼容
MY.WEB.NAMESPACE。
The current runtime target framework is not compatible with 'MY.WEB.NAMESPACE'.
当前运行目标框架:'DNX,版本V4.5.1 =(dnx451)'类型:
CLR体系结构:x86的版本:1.0.0-beta5-12103
Current runtime Target Framework: 'DNX,Version=v4.5.1 (dnx451)' Type: CLR Architecture: x86 Version: 1.0.0-beta5-12103
请确保运行时间匹配指定的框架
project.json
Please make sure the runtime matches a framework specified in project.json
我已经看到了所有的例子,到目前为止,似乎有两者的EntityFramework在同一个项目,但我使用的EntityFramework(目前版本6),在一个单独的项目。我的项目如下
All the examples i have seen so far, seem to have both EntityFramework in the same project, but i am using EntityFramework (currently version 6), in a separate project. My Projects are as follows
基建 - 有帮助的功能,任何项目中引用
Infrastructure - Helpful functions, referenced by any project
实体 - 我的POCO对象
Entities - My POCO objects
数据 - 我的DbContext类和其他数据库的具体code
Data - My DbContext class and other Database specific code
服务 - 我的服务,添加/更新实体,还引用SimpleValidation
我的验证
Service - My services to add/update entities, also references SimpleValidation for my validation
网站 - 我的web应用程序,其中包括的WebAPI和angularJs的
Web - My web application, which consists of WebApi and angularJs.
现在我对每一个项目,它看起来像所以project.json文件
Now i have a project.json file for each project, which looks like so
基建
{
"version": "1.0.0-*",
"description": "my.namespace.Infrastructure",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"System.Collections": "4.0.11-beta-23225",
"System.Linq": "4.0.1-beta-23225",
"System.Threading": "4.0.11-beta-23225",
"System.Runtime": "4.0.21-beta-23225",
"Microsoft.CSharp": "4.0.1-beta-23225",
"Humanizer": "1.37.7"
},
"frameworks": {
"net46": { }
}
}
的entites(POCOS)
ENTITES (POCOS)
{
"version": "1.0.0-*",
"description": "my.namespace.Entities",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"System.Collections": "4.0.11-beta-23225",
"System.Linq": "4.0.1-beta-23225",
"System.Threading": "4.0.11-beta-23225",
"System.Runtime": "4.0.21-beta-23225",
"Microsoft.CSharp": "4.0.1-beta-23225"
},
"frameworks": {
"net46": { }
}
}
DATA(的DbContext)
DATA (DBCONTEXT)
{
"version": "1.0.0-*",
"description": "my.namespace.Data",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"System.Collections": "4.0.11-beta-23225",
"System.Linq": "4.0.1-beta-23225",
"System.Threading": "4.0.11-beta-23225",
"System.Runtime": "4.0.21-beta-23225",
"Microsoft.CSharp": "4.0.1-beta-23225",
"DbExtensions": "5.1.0",
"my.namespace.Entities": "1.0.0-*",
"my.namespace.Infrastructure": "1.0.0-*",
"EntityFramework": "6.1.3"
},
"frameworks": {
"net46": { }
}
}
服务
{
"version": "1.0.0-*",
"description": "my.namespace.Service",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"System.Collections": "4.0.10-beta-23019",
"System.Linq": "4.0.0-beta-23019",
"System.Threading": "4.0.10-beta-23019",
"System.Runtime": "4.0.10-beta-23019",
"Microsoft.CSharp": "4.0.0-beta-23019",
"FluentValidation": "5.6.2",
"my.namespace.Entities": "1.0.0-*",
"my.namespace.Data": "1.0.0-*",
"my.namespace.Infrastructure": "1.0.0-*",
"ncalc": "1.3.8"
},
"frameworks": {
"net46": { }
}
}
我的Web应用程序,project.json看起来像这样
My web application, project.json looks like this
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"description": "my.namespace.Web",
"authors": [ "me" ],
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"AutoMapper": "4.0.4"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
},
"frameworks": {
"dnx5": {
"dependencies": {
"my.namespace.Infrastructure": "1.0.0-*",
"my.namespace.Entities": "1.0.0-*",
"my.namespace.Data": "1.0.0-*",
"my.namespace.Service": "1.0.0-*"
}
}
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
现在这一切似乎来构建精细,没有任何错误,但是当我尝试运行,我得到了上述消息。我看到另一篇文章这里这表明添加一个环境变量,但这似乎没有工作。
Now this all seems to build fine, with no errors, but when i try to run, i get the above message. I saw another post here which suggests adding an environment variable, but this doesnt seem to work.
如果我删除所有引用到我的其他项目中注释掉所有code引用其他项目,然后更改框架标签此,该网站的负载。
If i remove all the references to my other projects, comment out all code that references the other projects, and then change frameworks tag to this, the site loads.
"frameworks": {
"dnx45": {
"dependencies": {
}
}
},
任何帮助将大大AP preciated。
Any help would be greatly appreciated.
编辑。
下面是我的项目属性。
当我改变dnxcore5,我得到这个
When i change to dnxcore5, i get this
编辑2:
我已经更新了我所有的项目中使用dnx50和丢弃的dnxcore50。我仍然得到同样的错误。它必须是与我的安装....但我不知道...
I have updated all my projects to use dnx50 and dropped dnxcore50. I still get the same error. It must be something to do with my installation....But what i have no idea...
推荐答案
第一个目标的 DNX-CLR-双赢的x86 (适用于你的情况最有可能beta5的),因为你要在IIS上与运行此实体框架。检查您的解决方案的特性。也看看 global.json 解决方案中的文件夹中。请注意,运行目标的 CLR
First target dnx-clr-win-x86 (most likely beta5 in your case) since you want to run this on IIS with Entity Framework. Check your solution properties. Also have a look at global.json in your Solution Items folder. Please note that runtime targets clr.
"sdk": {
"version": "1.0.0-beta5",
"runtime": "clr",
"architecture": "x86"
}
更改dnx5(不存在),以dnx46并从所有project.json文件中删除dnxcore50。
Change dnx5 (this doesn't exist) to dnx46 and remove dnxcore50 from all project.json files.
"frameworks": {
"dnx46": {
"dependencies": {}
}
},
环境变量添加到您的web项目DNX_IIS_RUNTIME_FRAMEWORK:DNX46
Add an environment variable to your web project "DNX_IIS_RUNTIME_FRAMEWORK" : "DNX46"
的一个侧面说明,同β7已经是了,我建议你使用,而不用beta5的,也记得要升级dnvm。的
这篇关于ASP.NET 5 Web项目和Entity Framework在单独的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!