[英]One edmx file, multiple databases with different implementation - support mapping details
I have conceptual (domain) model which is implemented in different ways in separate databases. 我有概念(域)模型,该模型在不同的数据库中以不同的方式实现。 For example, inheritance in first db is table per type, second - concrete types are tables, and third - all types properties are merged in one table.
例如,第一个数据库中的继承是每种类型的表,第二个-具体类型是表,第三个-所有类型属性都合并在一个表中。 Something similar to this: Mapping objects to relational databases
与此类似:将对象映射到关系数据库
Also, i have two different data access layers (for now) - first is using Entity Framework 5 - Database first approach, and second is ADO.NET dynicamic DAL where i have my DB command factory. 另外,我有两个不同的数据访问层(目前)-首先是使用Entity Framework 5-数据库是第一种方法,其次是ADO.NET动态DAL,其中有我的DB命令工厂。
Client application will use these databases and client should choose on startup: 客户端应用程序将使用这些数据库,客户端应在启动时选择:
Depending on client's selection, system should use specified database, and selected DAL. 根据客户的选择,系统应使用指定的数据库并选择DAL。
My questions are: 我的问题是:
This may be too simple. 这可能太简单了。 Create a common class that inherits from all three base classes.
创建一个从所有三个基类继承的通用类。 The database class in the EDMX is always a partial class so create another partial class in the same namespace which is otherwise empty.
EDMX中的数据库类始终是部分类,因此请在同一名称空间中创建另一个部分类,否则该部分类为空。 Use your partial class to generate an interface.
使用您的局部类生成接口。
You can the create a domain class: 您可以创建一个域类:
public class myCommonClass : IDatabaseClass1, DatabaseClass2, DatabaseClass3
and then work with myCommonClass in your application. 然后在您的应用程序中使用myCommonClass。 You can then use Automapper to go between the database classes and the domain classes.
然后,您可以使用Automapper在数据库类和域类之间切换。 Automapper lives here .
Automapper住在这里 。
It's a Sunday morning so reply may be a little sketchy, and you're probably doing a lot of this anyway but ... 这是一个星期天的早晨,所以回复可能有点粗略,无论如何,您可能正在做很多事情,但是...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.