Fail in developing a plug in using Devart + ET [Oracle]

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
downwind
Posts: 19
Joined: Tue 19 May 2015 15:37

Fail in developing a plug in using Devart + ET [Oracle]

Post by downwind » Tue 19 May 2015 15:50

Dear Ladies/Gentlemen
I'm new to Devart, so I apologize in case of errors or misunderstanding.
I'm developing a "plug-in" (a DLL ) in C# that will be loaded in an internal application.
Since of the architecture, I can't get access to App.config file and connection string should be built within the code.

My last try looks this way:

Code: Select all

        private String getEntityConnectionString()
        {
            OracleConnectionStringBuilder oraCSB = new OracleConnectionStringBuilder();
            oraCSB.Direct = true;
            oraCSB.Server = "serverAddress";
            oraCSB.Port = 1521;
            oraCSB.Sid = "SID_DB";
            oraCSB.UserId = "USER";
            oraCSB.Password = "PASSWORD";

            EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
            builder.ProviderConnectionString = oraCSB.ConnectionString;
            builder.Metadata = "C:\\ConfigurationTest\\L2smp.csdl| C:\\ConfigurationTest\\L2smp.ssdl | C:\\ConfigurationTest\\L2smp.msl";
            builder.Provider = "Devart.Data.Oracle";

            return builder.ConnectionString;
        }
Usage of this string in my plug in has been implemented like this:

Code: Select all


String connectionString = getEntityConnectionString();
EntityConnection connection = null;
try
{
    connection = new EntityConnection(
}
catch (Exception e)
{
   /* Log and exit */
}
L3Core.Communication.DM.L2smp.L2smpModel context = new L3Core.Communication.DM.L2smp.L2smpModel(connectionString);

(L2smpModel is an ObjectContext)

Connection is successfully established; then at context creation I get the exception
L2smp.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'Devart.Data.Oracle'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
It's 3 days I'm stuck at this point, googling for a solution or at least some hints, unfortunately.

How can I get rid of it?

Cheers

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Fail in developing a plug in using Devart + ET [Oracle]

Post by Shalex » Wed 20 May 2015 09:35

downwind wrote:No Entity Framework provider found for the ADO.NET provider with invariant name 'Devart.Data.Oracle'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
You should add registration of EF6-provider via app.config / machine.config / code manually and rebuild the project (http://blog.devart.com/entity-framework ... gistration):

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=8.4.407.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Devart.Data.Oracle" />
      <add name="dotConnect for Oracle" invariant="Devart.Data.Oracle" description="Devart dotConnect for Oracle" type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=8.4.407.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
</configuration>
Replace 8.4.407 here with your current version of dotConnect for Oracle. Please note that the revision number of provider in the entityFramework section is *.6 (8.4.407.6) but it should be *.0 (8.4.407.0) in DbProviderFactories.
downwind wrote:Since of the architecture, I can't get access to App.config file and connection string should be built within the code.
The same question but about dotConnect for SQLite was discussed at http://forums.devart.com/viewtopic.php?t=28550. Try applying the same recommendations with dotConnect for Oracle. If you encounter any difficulties, please describe the issue.

downwind
Posts: 19
Joined: Tue 19 May 2015 15:37

Re: Fail in developing a plug in using Devart + ET [Oracle]

Post by downwind » Wed 20 May 2015 10:27

Thanks for your reply. I started following the given suggestions, but at the very first step it's requested to add the following code (I've adapted for Oracle):

Code: Select all

    public class MyContext: ObjectContext
    {
        static MyContext()
        {
            DbConfiguration.SetConfiguration(new Devart.Data.Oracle.Entity.OracleEntityProviderServicesConfiguration());
        }
    }
and I'm getting the (reasonable)compile error:
error CS1729: 'System.Data.Objects.ObjectContext' does not contain a constructor that takes 0 arguments

As you may see, code is exactly the same as posted, the only difference is the replacement of "Oracle" DB Name instead of "SQlite".
I suppose the version in use on that post has a default constructor...

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Fail in developing a plug in using Devart + ET [Oracle]

Post by Shalex » Wed 20 May 2015 12:13

downwind wrote:'System.Data.Objects.ObjectContext' does not contain a constructor that takes 0 arguments
Your context inherits ObjectContext but the context in the sample inherits DbContext.

Try using your current approach with an implementation of the following code-based registrations:

1. <DbProviderFactories>

Code: Select all

        private static void InitDbProvFactEntry()
        {
            bool DevartProviderRegistered = false;
            var dataSet = System.Configuration.ConfigurationManager.GetSection("system.data") as System.Data.DataSet;
            foreach (System.Data.DataRow dr in dataSet.Tables[0].Rows)
            {
                if ((string)dr[2] == "Devart.Data.Oracle")
                {
                    DevartProviderRegistered = true;
                }
            }
            if (!DevartProviderRegistered)
            {
                dataSet.Tables[0].Rows.Add("dotConnect for Oracle"
                    , "Devart dotConnect for Oracle"
                    , "Devart.Data.Oracle"
                    ,
                    "Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=" + Devart.Data.Oracle.ProductInfo.Version + ", Culture=neutral, PublicKeyToken=09af7300eec23701");
            }
        }
2. <entityFramework> (EF6)

Code: Select all

        private static void InitEFEntry()
        {
            DbConfiguration.SetConfiguration(new Devart.Data.Oracle.Entity.OracleEntityProviderServicesConfiguration());
        }
References to the Devart.* assemblies in the project:
C:\Program Files (x86)\Devart\dotConnect\Oracle\Devart.Data.dll
C:\Program Files (x86)\Devart\dotConnect\Oracle\Devart.Data.Oracle.dll
C:\Program Files (x86)\Devart\dotConnect\Oracle\Entity\EF6\Devart.Data.Oracle.Entity.dll

downwind
Posts: 19
Joined: Tue 19 May 2015 15:37

Re: Fail in developing a plug in using Devart + ET [Oracle]

Post by downwind » Wed 20 May 2015 13:47

I apologize but as I said I'm a newbie. I've double checked the assemblies I'm going to use, figured out I included a wrong set and updated according to your post. Once I done that, the previous posted code:

Code: Select all

    public class MyContext: DbContext
    {
        static MyContext()
        {
            DbConfiguration.SetConfiguration(new Devart.Data.Oracle.Entity.OracleEntityProviderServicesConfiguration());
        }
    }
has been built successfully.
I should now go ahead, but I didn't get whether should I follow the "sqlite" post or continue with the next suggestion you provided. Moreover, does "1. <DbProviderFactories>" mean I should create a new class and inherit from it?

Sorry for those questions, it's my first project with this technology

downwind
Posts: 19
Joined: Tue 19 May 2015 15:37

Re: Fail in developing a plug in using Devart + ET [Oracle]

Post by downwind » Wed 20 May 2015 14:01

Sorry, I was faster in writing than thinking. I've double checked you snipped and usage was clear.
I've tried and everything look fine, now! I'm performing further checks but the ones I did up to now have been successfully accomplished. Great!

Cheers
Downwind

Post Reply