简体   繁体   English

使用edmgen工具生成实体框架类后达到错误

[英]Error reached after genereated entity framework classes by edmgen tool

First I read this question , but this knowledge did not help to solve my problems. 首先,我阅读了这个问题 ,但是这种知识并不能帮助解决我的问题。

In initial I've created edmx file by Visual Studio. 最初,我是通过Visual Studio创建edmx文件的。 Generated files with names: 生成的文件名称为:

  • uqsModel.Designer.cs uqsModel.Designer.cs
  • uqsModel.edmx uqsModel.edmx

This files are located on App_Code folder. 此文件位于App_Code文件夹中。

And my web app work normally. 而且我的网络应用程序正常工作。 In Web Config generated connectionstring automatically. 在Web Config中自动生成连接字符串。

<add name="uqsEntities" connectionString="metadata=res://*/App_Code.uqsModel.csdl|res://*/App_Code.uqsModel.ssdl|res://*/App_Code.uqsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=aemloviji\sqlexpress;Initial Catalog=uqs;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" /></connectionStrings>

Then I had to generate classes by the instrument edmgen tool (full generation mode). 然后,我必须通过仪器edmgen工具 (完整生成模式)生成类。 Generated new files with names: 生成的新文件的名称为:

  • uqsModel.cs uqsModel.cs
  • uqsModel.csdl uqsModel.csdl
  • uqsModel.msl uqsModel.msl
  • uqsModel.ssdl uqsModel.ssdl
  • uqsViews.cs uqsViews.cs

it save new classed to the folder where edmx files located before, and remove existing edmx files. 它将新分类保存到edmx文件之前所在的文件夹中,并删除现有的edmx文件。 And when page redirrects to any web page server side code fails. 当页面重新定向到任何网页服务器端代码时失败。 And problem: Unable to load the specified metadata resource . 问题: 无法加载指定的元数据资源

Some idea, please. 请给我个主意。

The problem seems to be associated with the fact that you have generated metadata in the form of .csdl, .ssdl, and .msl files, and your connection string points to the resource that should be embedded to the project dll (which is likely to be unavailable in your Web Site). 该问题似乎与以下事实有关:您已生成.csdl,.ssdl和.msl文件形式的元数据,并且您的连接字符串指向应嵌入到项目dll中的资源(这很可能会在您的网站上不可用)。
The solution is to correct the path to metadata like the following: 解决方案是更正元数据的路径,如下所示:

metadata=~\App_Code\uqsModel.csdl|~\App_Code\uqsModel.ssdl|~\App_Code\uqsModel.msl

More information is available here . 在此处获得更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM