Mono failed to load data provider

Mono failed to load data provider

Postby smokeing » Tue 03 Nov 2015 15:49

I'm trying to use dotConnect Oracle under Mono.
I have added compiled license - licensing works.

I'm initializing dotConnect using code approach:
Code: Select all
static ContextFactory()
        {
            var config = OracleEntityProviderConfig.Instance;
            config.CodeFirstOptions.ColumnTypeCasingConventionCompatibility = false;
            config.SpatialOptions.SpatialServiceType = SpatialServiceType.NetTopologySuite;
            DbConfiguration.SetConfiguration(new Devart.Data.Oracle.Entity.OracleEntityProviderServicesConfiguration());
        }


Code: Select all
        public Context CreateContext()
        {
            var entityBuilder = new EntityConnectionStringBuilder()
            {
                Provider = "Devart.Data.Oracle",
                ProviderConnectionString = _dbConfiguration.SqlConnectionString,
                Metadata = @"res://Database/Db.csdl|
res://Database/Db.ssdl|
res://Database/Db.msl"
            };
            return new Context(entityBuilder.ToString());
        }


When I try to evaluate IQueryable interface it throws an error:
Error Code: ConfigurationErrors
ExceptionMessage: Failed to find or load the registered .Net Framework Data Provider 'Devart.Data.Oracle'.


Connection to the database works. I am checking it during app startup like this:
Code: Select all
            using (var conn = new OracleConnection(SqlConnectionString))
            {
                try
                {
                    conn.Open();
                }
                catch (Exception e)
                {
                    return false;
                }
                conn.Close();
            }
            return true;


Devart dlls are added to GAC (except Spatials which is copied to bin folder). My app loads them without fail:
Application Output:
Loaded assembly: /usr/lib/mono/gac/Devart.Data.Oracle/8.5.521.0__09af7300eec23701/Devart.Data.Oracle.dll
Loaded assembly: /usr/lib/mono/gac/Devart.Data/5.0.1313.0__09af7300eec23701/Devart.Data.
Loaded assembly: /usr/lib/mono/gac/Devart.Data.Oracle.Entity/8.5.521.6__09af7300eec23701/Devart.Data.Oracle.Entity.dll
Loaded assembly: /home/smokeing/server/bin/Debug/Devart.Data.Oracle.Entity.Spatials.dll


Under .NET (windows) it works perfectly. What am I doing wrong?
smokeing
 
Posts: 23
Joined: Fri 09 Oct 2015 00:51

Re: Mono failed to load data provider

Postby Shalex » Wed 04 Nov 2015 13:50

Please make sure that your app.config includes the following entries:
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.5.521.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.5.521.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
</configuration>


Replace 8.5.521 here with your current version of dotConnect for Oracle. Please note that the revision number of provider in the entityFramework section is *.6 but it should be *.0 in DbProviderFactories.
Shalex
Devart Team
 
Posts: 7612
Joined: Thu 14 Aug 2008 12:44

Re: Mono failed to load data provider

Postby smokeing » Wed 04 Nov 2015 14:09

Now it throws Metadata Exception: Unable to load the specified metadata resource.

According to dotPeek assembly compiled using Mono doesn't have metadata resources.
smokeing
 
Posts: 23
Joined: Fri 09 Oct 2015 00:51

Re: Mono failed to load data provider

Postby Shalex » Wed 04 Nov 2015 15:36

Try changing the "Metadata Artifact Processing" model property value from "Embed In Output Assembly" to "Copy To Output Directory". Save the model, rebuild the project on Windows to make sure it works, and deploy on Mono.
Shalex
Devart Team
 
Posts: 7612
Joined: Thu 14 Aug 2008 12:44

Re: Mono failed to load data provider

Postby smokeing » Wed 04 Nov 2015 16:00

How then MetadataString should look like? Dll compiled on windows runs on mono. I am trying to compile app using xbuild on mono.
smokeing
 
Posts: 23
Joined: Fri 09 Oct 2015 00:51

Re: Mono failed to load data provider

Postby Shalex » Thu 05 Nov 2015 19:24

smokeing wrote:I am trying to compile app using xbuild on mono.
Please generate *.ssdl / *.msl / *.csdl on your Windows, add them to your project on Mono with BuildAction=EmbeddedResource.
Shalex
Devart Team
 
Posts: 7612
Joined: Thu 14 Aug 2008 12:44

Re: Mono failed to load data provider

Postby smokeing » Thu 12 Nov 2015 13:56

Shalex wrote:Please make sure that your app.config includes the following entries: ...


Is there a way to use dotConnect without XML configuration file?
smokeing
 
Posts: 23
Joined: Fri 09 Oct 2015 00:51

Re: Mono failed to load data provider

Postby Shalex » Fri 13 Nov 2015 15:10

You can add registration of EF6 provider and the DbProviderFactories section in code like it is described in this thread: http://forums.devart.com/viewtopic.php?f=29&t=28550.

Notes:
1. It was not tested with Mono.
2. The thread is about dotConnect for SQLite, but you can adjust it for using dotConnect for Oracle. The corresponding documentation:
https://www.devart.com/dotconnect/oracle/docs/?deployment.html
http://blog.devart.com/entity-framework-6-support-for-oracle-mysql-postgresql-sqlite-and-salesforce.html
Shalex
Devart Team
 
Posts: 7612
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle