Page 1 of 1
Cross-DBMS access with single model
Posted: Wed 25 Sep 2013 14:26
by Andrei Lisin
My application should support oracle and mssql with EF5. Is it possible with single model and classes generated from it? As I understand, I would need at least a different SSDL and connection string for different databases. Is that enough? Can it work at all?
Re: Cross-DBMS access with single model
Posted: Thu 26 Sep 2013 12:59
by Shalex
Usage of SQL Server and Oracle simultaneously in one application can be implemented in the following alternative ways:
1. Creating repositories for 2 models
2. Using mapping which is loaded dynamically:
2.1. With 2 *.edmx (or 2 *.edml). Only one of them generates the code of model and entity classes, another one is used as a source of XML resources (example:
http://www.devart.com/efquerysamples.zip)
2.2. Only one model and database independent fluent mapping:
http://blog.devart.com/entity-developer ... plate.html
3. Code-First approach:
http://blog.devart.com/entity-framework ... qlite.html. This article includes reference to the sample "Code-First for All Databases" which shows the way how to access different databases with the same code.
Despite the approach you will choose, we recommend you to employ Devart Entity Model (*.edml):
http://www.devart.com/entitydeveloper/ed-vs-edm.html.
Re: Cross-DBMS access with single model
Posted: Thu 17 Oct 2013 14:15
by Andrei Lisin
Entity Developer generates ObjectContext.
http://blogs.devart.com/dotconnect/enti ... plate.html
Following that, we remove the standard code generation template and enable the DbContext template.
Ermm... how?
Re: Cross-DBMS access with single model
Posted: Thu 17 Oct 2013 14:49
by Shalex
Navigate to View > Model Explorer (in a standalone Entity Developer) or Tools > Entity Developer > Model Explorer (in Visual Studio), open the Templates node, remove EntityObject and add DbContext.