使用 EntityFramework 支持 SQL Server 或 Oracle 作为数据存储层
我想开发一款支持使用 SQL Server 或 Oracle 作为其数据存储层的软件。
我可以使用实体框架来实现这一目标吗?我的系统的架构将如何?在这种情况下有什么建议/最佳实践吗?
感谢您的帮助。
I want to develop a software that will support using either SQL Server or Oracle as its Data Store layer.
Can I use Entity Framework to achieve that? How will be the architecture of my system. And are there any recommendations/best practicies in that case?
Appreciate your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,根据您的评论,我认为您需要编写两个不同的 EDMX 文件,其中 CSDL 部分(设计器中显示的实体)必须完全相同。
EDMX 文件由四部分组成:
编译时 EDMX 被分解为作为资源附加的三个 xml 文件(ssdl、msl 和 csdl)到包含的程序集。然后从 EF 连接字符串引用这些文件。
您必须将 EFv4 与 POCO 实体结合使用,这将允许您在多个 EDMX 之间共享一组实体,因为 POCO 实体通过命名约定与图中定义的实际实体相关。
可以强制 EF 将这三个 XML 存储在文件中而不是资源中,以便您可以在运行时共享 CSDL 部分,但对于需要 EDMX 而不是分离部分的设计器来说仍然不起作用。
Ok based on your comments I think you need to compose two different EDMX files where CSDL part (the entities shown in the designer) must be exactly the same.
EDMX file consists of four parts:
When compiled EDMX is decomposed to three xml files (ssdl, msl and csdl) attached as resources to the containing assembly. These files are then referenced from the EF connection string.
You will have to use EFv4 with POCO entities which will allow you to share single set of entities among multiple EDMXs because POCO entities are related to real entities defined in the diagram by naming conventions.
It is possible to force EF to store those three XMLs in files instead of resources so you can share CSDL part at runtime but still it will not work for the designer where you need EDMX and not separated parts.