Search code examples
.netsql-serveroracleentity-frameworkdatastore

Support either SQL Server or Oracle for the Data Store layer using EntityFramework


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.


Solution

  • 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:

    • SSDL - database description dependent on database provider
    • CSDL - entities description
    • MSL - mapping between SSDL and CSDL
    • Designer related informations about diagram

    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.