Page 1 of 1

InvalidOperationException when a 2 db system ( Oracle & SQLServer) is initialized

Posted: Thu 07 Apr 2016 10:33
by darioaxel
Hi,

We´re developing a system that needs two different databases. Each client has its own old db in Oracle or SQLServer from where we get info, and the new project SQLServer db with migrations.

If the client uses also SQLServer, the project build without problems and can be deployed nicely. But as soon as the system is mixed ( the client uses Oracle) we get an InvalidOperationException when the Database.SetInitializer method is called.
The system tries to execute this select:

Code: Select all

select cast(serverproperty('EngineEdition') as int) 
over the SQLServer db without event existing and the result is null, so the deploy fails.

Did anyone deal with something similar or know what can be happening?

Connectionstrings seem to be fine, but we have no idea what can be failing..

Code: Select all

    <add name="EPDbConnection" connectionString="Server=DBSERVER;Database=HR.EP;Trusted_Connection = True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
    <add name="ClientDbConnection" connectionString="user id=FOO; password=TOO; Host=172.0.0.1; Service Name=oracle10; Port=1522; Direct=true;" providerName="Devart.Data.Oracle" />

Re: InvalidOperationException when a 2 db system ( Oracle & SQLServer) is initialized

Posted: Fri 08 Apr 2016 06:19
by Shalex
darioaxel wrote:We´re developing a system that needs two different databases. Each client has its own old db in Oracle or SQLServer from where we get info, and the new project SQLServer db with migrations.
We recommend you to use the following approach: one base context, two descendants for each provider. Each descendant should have its own configuration and code-first code-based migrations.

An EF Code-First sample is available at http://blog.devart.com/entity-framework ... ml#Samples.
The dotConnect-specific notes about EF Code-First Migrations are here: http://blog.devart.com/entity-framework ... qlite.html.