0 Replies Latest reply on Apr 14, 2016 2:29 PM by b756acb2-288a-475e-ae9a-8412d5da8f8e

    Adding Oracle.ManagedDataAccess reference breaks existing Entity Framework

    b756acb2-288a-475e-ae9a-8412d5da8f8e

      We have been using Entity Framework for several year starting with EF4, now up to EF6. All of the databases we interface with are Microsoft SQL Server. We have been using many Visual Studio versions, from 2010 through to the current 2015. We have an ASP.NET MVC application with many included helper assemblies and libraries. The EF classes are defined in the main web project. We have several MVC controllers, two of which reference the EF classes. Everything worked fine for years.

       

      This week, I created a new helper library project to interop with an Oracle database that was new to my team. I added a reference to Oracle.ManagedDataAccess.dll in the project's References. I was able to connect to the Oracle database, using code as below:

       

      using System.Data;

      using Oracle.ManagedDataAccess.Client;

       

      namespace Eship

      {

      public static class EshipLib

      {

      public static void PlaceOrder(WebPreorder order)

      {

        string connString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=machinename.blah.org)(PORT=50001)))(CONNECT_DATA=(SERVICE_NAME=servicename.blah.org)));User Id=somename;Password=foobar;";

        using (var conn = new OracleConnection(eshipConnString))

        {

        conn.Open()

       

        var cmd = new OracleCommand();

        cmd.Connection = conn;

        cmd.CommandType = CommandType.Text;

        cmd.CommandText = string.Format("insert into ORDER" +

        "(CREATION_DATE, CREATED_BY) " +

        "values " +

        "( " +

        "TO_DATE('{0:yyyy-MM-dd}', 'yyyy-mm-dd')," +

        "{1} )",

        order.creationDate,

        order.createdBy,

        );

        int rows = cmd.ExecuteNonQuery();

        }

      }

      }

      }

       

      I don't think the code it really relevant, but I include it to show that I am successfully connecting without benefit of a sqlnet.ora or a tnsnames.ora. This code does work, and I am able to connect to the database and insert the data. This library is compiled into an assembly project that is referenced in the main web project by an MVC controller different from the ones that reference the EF SQL Server classes. An example structure might look like this:

       

      Rootsite Project

      (EF assembly references)

      FirstController

      EF SQL Server class

      SecondController

      EF SQL Server class

      NewController

      OracleHelper class reference

       

      Helper Projects

      OracleHelper Project

      (Oracle.ManagedDataAccess reference)

      OracleHelper class

       

      Here is where the problem arises. The two web pages that use EF to talk to SQL Server still work if I go to them first, before going to my new Oracle-referencing controller/site. However, if at any time I go to my site that references the Oracle assembly, my EF sites become broken and never recover. Below is the error I get:

       

      Schema specified is not valid. Errors:

      Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(2,64) : error 0175: The specified store provider cannot be found in the configuration, or is not valid.

      Some.Namespace.PresentationModel.ssdl(2,55) : error 0172: All SSDL artifacts must target the same provider. The Provider 'Oracle.DataAccess.Client' is different from 'Oracle.DataAccess.Client' that was encountered earlier.

      Some.Namespace.PresentationModel.ssdl(2,88) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '2008' is different from '9.2' that was encountered earlier.

       

      It is almost like Oracle is inserting itself in the EF stack somehow, and breaking the existing EF implementations. Just some more notes that may not be relevant, but that I have uncovered in my research: Oracle.ManagedDataAccess is not in the GAC, nor is it referenced in the machine.config. This issue is affecting my development machine, as well as a "real" test web server. There are no errors at compile time, only at run time. I am using Oracle.ManagedDataAccess.dll with a file version of 4.121.2.0.

       

      Should I be adding Oracle to the EF stack, if only to tell EF not to use it? I am baffled...

       

      Thank you,

       

      -Fred