多个“ObjectChangeTracker”得到创造,可以避免吗? [英] Multiple "ObjectChangeTracker" getting created, can it be avoided?

查看:68
本文介绍了多个“ObjectChangeTracker”得到创造,可以避免吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您好,


Hi,

我们正在开发一个POC,我们拥有以下架构(MVVM),

We are working on a POC where we have following architecture (MVVM),

WPF(客户端)+ WCF +模型(DataAccess)+ ADO.Net实体框架4.0(使用SQL Server 2008 R2作为数据库)

WPF(Client) + WCF + Model(DataAccess)+ ADO.Net Entity Framework 4.0 (with SQL Server 2008 R2 as DB)

所有都是不同的项目。

在DataAccess层中,我们根据功能创建了不同的实体模型(edmx)。针对特定流程的表格被分组并创建不同的实体模型。我们使用自我跟踪实体来通过wcf服务与WPF
客户端进行通信。对于单一型号,一切正常。但是当我们创建一个多模型时,很少有问题开始出现。多重模型具有很少的重复表/实体。两个问题是,

In the DataAccess layer we have created different Entity Models(edmx) based on the functionality. The tables under perticular flow are grouped and created different entity models. We are using self tracking entities to and fro to communicate with the WPF client through wcf service. For Single model everything works fine. But when we created a Multiple models then few issues started coming. Mutliple models have few duplicate tables/entities. Two probels are,

1)当我们尝试从不同模型访问实体时,多个对象"ObjectChangeTracker"正在创建。

 例如¥b $ b   CompanyModel(edmx) - 公司(实体) - ObjectChangeTracker,ObjectState

    ProductModel(edmx) - 客户(实体) - ObjectChangeTracker1,ObjectState1

   OrderModel(edmx) - Oder(实体) - ObjectChangeTracker2,ObjectState2

1) When we try to access entities from different models mutiple objects "ObjectChangeTracker" are getting created.
 E.g.
  CompanyModel(edmx) - Company(Entity) - ObjectChangeTracker, ObjectState
  ProductModel(edmx) - Customer(Entity) - ObjectChangeTracker1, ObjectState1
  OrderModel(edmx) - Oder(Entity) - ObjectChangeTracker2, ObjectState2

有什么办法可以避免这种情况吗?

Is there any way to avoid this?

2)很少有表格在模型中共享,例如公司(实体)用于以上所有的门户。在编译期间,它不会产生任何错误。但是运行时它给出错误说"指定的模式无效"。错误:CLR类型到
EDM类型的映射是不明确的,因为多个CLR类型与EDM类型"公司"匹配。"为了解决这个问题,我们将具有一些前缀的实体重命名为使其成为唯一。有没有其他方法可以解决这个问题,而无需在同一个程序集中更改实体的名称?

2) There are few tables which shared across the Models, E.g. Company(Entity) is used in All above mdoels. During compile time it does not thow any error. But run time It gives error saying "Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type "Company"".. To resolve this, we renamed the entities with some prefix to make them Unique. Is there any other way we can resolve this without changing the name of the entity in the same assembly?

提前致谢并感谢所有人都有解决这些问题的方法。

Thanks in advance and appreciate if anyone has approach for these issues.

谢谢,

Kiran

 

Thanks,
Kiran
 

推荐答案

我们正在开发一个POC,我们有以下架构(MVVM),

We are working on a POC where we have following architecture (MVVM),

WPF (客户端)+ WCF +模型(DataAccess)+ ADO.Net实体框架4.0(使用SQL Server 2008 R2作为数据库)

WPF(Client) + WCF + Model(DataAccess)+ ADO.Net Entity Framework 4.0 (with SQL Server 2008 R2 as DB)

所有都是不同的项目。

在DataAccess层中,我们根据功能创建了不同的实体模型(edmx)。针对特定流程的表格被分组并创建不同的实体模型。我们使用自我跟踪实体来通过wcf服务与WPF
客户端进行通信。对于单一型号,一切正常。但是当我们创建一个多模型时,很少有问题开始出现。多重模型具有很少的重复表/实体。两个问题是,

In the DataAccess layer we have created different Entity Models(edmx) based on the functionality. The tables under perticular flow are grouped and created different entity models. We are using self tracking entities to and fro to communicate with the WPF client through wcf service. For Single model everything works fine. But when we created a Multiple models then few issues started coming. Mutliple models have few duplicate tables/entities. Two probels are,

1)当我们尝试从不同模型访问实体时,多个对象"ObjectChangeTracker"正在创建。

 例如
  CompanyModel(edmx) - 公司(实体) - ObjectChangeTracker,ObjectState

  ProductModel(edmx) - 客户(实体) - ObjectChangeTracker1,ObjectState1

  OrderModel(edmx) - Oder(实体) - ObjectChangeTracker2,ObjectState2

1) When we try to access entities from different models mutiple objects "ObjectChangeTracker" are getting created.
 E.g.
  CompanyModel(edmx) - Company(Entity) - ObjectChangeTracker, ObjectState
  ProductModel(edmx) - Customer(Entity) - ObjectChangeTracker1, ObjectState1
  OrderModel(edmx) - Oder(Entity) - ObjectChangeTracker2, ObjectState2

有什么方法可以避免这种情况吗?

Is there any way to avoid this?

2)表中有几个在模型中共享,例如公司(实体)用于以上所有的门户。在编译期间,它不会产生任何错误。但是运行时它给出错误说"指定的模式无效"。错误:CLR类型到
EDM类型的映射是不明确的,因为多个CLR类型与EDM类型"公司"匹配。"为了解决这个问题,我们将具有一些前缀的实体重命名为使其成为唯一。有没有其他方法可以解决这个问题,而无需在同一个程序集中更改实体的名称?

2) There are few tables which shared across the Models, E.g. Company(Entity) is used in All above mdoels. During compile time it does not thow any error. But run time It gives error saying "Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type "Company"".. To resolve this, we renamed the entities with some prefix to make them Unique. Is there any other way we can resolve this without changing the name of the entity in the same assembly?

提前致谢并感谢所有人都有解决这些问题的方法。

Thanks in advance and appreciate if anyone has approach for these issues.

谢谢,

Kiran

Thanks,
Kiran


这篇关于多个“ObjectChangeTracker”得到创造,可以避免吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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