项目可以有两个不同的参考同一个表的EF数据模型吗? [英] Can a project have two different EF data models that reference the same table?

查看:156
本文介绍了项目可以有两个不同的参考同一个表的EF数据模型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有主要数据模型来执行大部分工作的系统。



该模型有很多表格,而且考虑到性能当我向应用程序添加一个管理功能时,我决定使用第二个单独的数据模型。



一直运行良好,直到我的第二个数据模型需要访问也在主数据模型中的表。现在,从挖掘中可以看到这可能会导致问题



我想出的两个可能的解决方法是:


  1. 将数据模型在单独的项目中。

  2. 在需要时使用视图/存储过程来访问有问题的表。

方法1似乎是最简单的,但我担心是否会有任何性能损失。方法2似乎有点混乱,并指出使用EF。



在我丰满使用方法1之前,有没有更容易的工作,我可以使用? / p>

解决方案

最后我决定把这两个数据模型放在单独的项目中,我没有任何放缓我已经能够注意到(我没有做任何基准测试,但是通过了感知测试)。



在她的在线教程之一,EF guru Julie Lerman说无论如何,您应该将数据模型放在单独的项目中,所以我不要认为这是一个坏的解决方法。


I've system that has a primary data model to perform most of the work.

The model has quite a few tables and with performance in mind when I came to add an administrative feature to the application I decided to use a second separate data model.

All works well until my second data model needs to access a table that is also in the primary data model. Now, from digging around I can see this can cause problems.

The two possible workaround I've come up with are to either:

  1. Put the data models in separate projects.
  2. Use views / stored procedures for accessing the table in question when required.

Method 1 seems the simpliest but I'm concerned about whether there would be any performance loss. Method 2 seems a bit messy and takes the point out of using EF.

Before I plump for using method 1, is there an easier work around that I could use?

解决方案

In the end I decided to put the two data models into separate projects and I've there hasn't been any slowdown that I've been able to notice (I've not done any benchmarking but it's passed the perception test).

In one of her online tutorials EF guru Julie Lerman says that you should put your data model in a separate project anyway, so I don't think this has been a bad workaround.

这篇关于项目可以有两个不同的参考同一个表的EF数据模型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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