[已解决]两个具有相同结构和ADO.NET实体数据模型的数据库 [英] [SOLVED]Two Databases with same structure and ADO.NET Entities DataModel

查看:72
本文介绍了[已解决]两个具有相同结构和ADO.NET实体数据模型的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在使用C#.NET编程时遇到问题:
我有两个结构相同的数据库(相同的表和字段),而当我为两个数据库创建数据模型时,问题就来了.当我进行这样的LINQ查询时:

var qry =来自ctx.t中的t 其中t.Field = 0
选择t;

Visual Studio说:
多次定义该成员"错误:"Project.Table.Field"和"Project.Table.Field"之间存在歧义
似乎VS无法识别它们是不同的数据库.
你能给我些帮助吗?我会很感激的.

提前谢谢.
最好的问候.

-编辑-
解决方案:
感谢布雷迪·凯利(Brady Kelly)的回复.我进行了更多搜索,发现该解决方案位于数据模型的属性中,更改了自定义工具命名空间"的值.提供不同的名称空间效果很好!

Hi everybody, i''m having a problem while programming on C#.NET:
I have two databases with the same structure(same tables and fields), and the problem comes when i create the DataModels for both. When i make a LINQ query like this:

var qry = from t in ctx.Table
where t.Field = 0
select t;

Visual Studio says:
"The member is defined more than once" Error: Ambiguity between ''Project.Table.Field'' and ''Project.Table.Field''
It seems to be that VS can''t recognize that they are differents DataBases.
Can you give me some help? I''ll apreciate it.

Thanks in advance.
Best Regards.

-- EDIT --
SOLUTION:
Thanks to Brady Kelly for the reply.I´ve searched a little more and i´ve found that the solution is in a property of the Data Model, changing the value of "Custom Tool Namespace". Giving different namespaces works great!

推荐答案

在这种情况下,您需要注意名称空间.您的模型必须位于单独的名称空间中,但是我发现,当您从数据库生成模型时,尽管向导要求您提供名称空间,但该向导仍会使用添加了模型的文件夹的名称空间来生成代码.如果您的两个模型都在项目根目录下,则很有可能它们都在同一个命名空间中.
You need to pay attention to namespaces in scenarios like this. Your models have to be in separate namespaces, but I''ve found that when you generate a model from a DB, although the wizard asks you for a namespace, it still generates code with a namespace of the folder you add the model to. If both your models are under the project root, there is good chance they are in the same namespace.


这篇关于[已解决]两个具有相同结构和ADO.NET实体数据模型的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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