一个项目中有多个edmx [英] Multiple edmx in one project

查看:79
本文介绍了一个项目中有多个edmx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有一个edmx文件的项目。测试类正常工作。当我添加具有不同名称和名称空间的edmx,但连接到类似的基本结构时,在添加之后,在代理类停止工作之前,我得到以下消息:

I have a project with one edmx file. Test class works correctly.when i add the edmx with a different name and namespace, but connect to a similar base structure ,After the addition, before acting classes stops working and I get the message:

 Mapping and metadata information could not be found for EntityType
 (InvalidOperationException)

一旦我删除添加的edmx,该项目就可以正常工作。是否可以将两个edmx文件添加到一个项目中,以免出现对元数据的错误引用?

Once i delete the added edmx, the project is working properly.Is there a possibility of adding two edmx files to a single project, so as not to appear to be erroneous references to the metadata?

当前我使用此连接字符串

<add name="MSSQLEntities" connectionString="metadata=res://*/RiskEntityModel.csdl|res://*/RiskModelLibrary.Lib.RiskEntityModel.MSSQL.ssdl|res://*/RiskEntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=_DBSERVERNAME_;User ID=_DBUSERNAME_;Password=_DBPASSWORD_;Initial Catalog=_DBPATH_;Trusted_Connection=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />


推荐答案

您必须构造 EntityConnectionDescription 并将其传递给 ObjectContext 的自定义实现。

You've got to construct EntityConnectionDescription manually and pass it to your custom implementation of ObjectContext.

基本上而不是标准的EF上下文构建功能(可从应用程序配置读取),而是您自己创建的。

So basically instead of standard EF context-buildup functionality (which reads from app config) you create your own.

这篇关于一个项目中有多个edmx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆