Page 1 of 1

weird problem in context creation

Posted: Mon 01 Jun 2015 07:47
by downwind
Ladies/Gentlemen
I create a context by mean of

Code: Select all

    public class L2SmpQuery : IQuery
    {
        public L2SmpQuery()
        {
            // Configuration change. Workaround from Devart forum
            var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
            config.CodeFirstOptions.ColumnTypeCasingConventionCompatibility = false;
            String connectionString = getEntityConnectionString();
            context = new L3Core.Communication.DM.L2smp.L2smpModel(connectionString);
        }

        private String getEntityConnectionString()
        {
            OracleConnectionStringBuilder oraCSB = new OracleConnectionStringBuilder();
            oraCSB.Direct = true;
            oraCSB.Server = "xxx";
            oraCSB.Port = 1521;
            oraCSB.Sid = "SMCDB";
            oraCSB.UserId = "L2SMC";
            oraCSB.Password = "xx";

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

            return builder.ConnectionString;
        }
      .....
(I've declared IQuery as general interface because the software using it shouldn't know about the current data model).

Using it is straightforward:

Code: Select all

IQuery controlQueryHandler = new L2SmpQuery();
This statement should be executed in two different projects. It's executed successfully in the first project, while the second raises an exception:
Schema specified is not valid. Errors: \r\nL2smp.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.

Software is exactly the same as well as the connection string. Any idea on what I'm doing wrong?

Cheers

Re: weird problem in context creation

Posted: Mon 01 Jun 2015 15:16
by Shalex
You should add registration of EF6-provider in the app.config file of each application which uses the context via dotConnect for Oracle (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.422.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.422.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
</configuration>
Replace 8.4.422 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.422.6) but it should be *.0 (8.4.422.0) in DbProviderFactories.

Re: weird problem in context creation

Posted: Fri 05 Jun 2015 15:05
by downwind
Thanks for your suggestion; indeed, code is developed as a plug-in and there's no app.config file.
Registration is thru connection string (apparently).
I've copied the same connection string on both projects.
In practice, I've 3 projects: one just exports EF classes, and such classes should be used in the other 2 projects.
Strangely, one project can use such classes successfully while the other throws an exception.

As I said, I'm a newby and maybe the problem can be a misunderstanding or erroneous configuration.
Is there a checklist of possible failures I should check? It looks impossible having two projects, getting connected in the same way and having so different behavior...

Re: weird problem in context creation

Posted: Fri 05 Jun 2015 16:27
by Shalex
You mean a checklist for the "No Entity Framework provider found for the ADO.NET provider with invariant name 'Devart.Data.Oracle'" error, don't you? The registration of EF provider can be implemented either via app.config or via code (links to our previous discussion).

Re: weird problem in context creation

Posted: Mon 08 Jun 2015 10:15
by downwind
I've double checked once again, but I can't get rid of the problem.
- I've one .dll containing the Data model;
- I've 2 .dlls using such model;
+ the first includes and uses the model without any problem. It's the one you helped me in previous discussion;
+ I've copied the same code into the second dll (i.e. connection string + settings you suggested), added the same references (DevArt.Data, DevArt.Data.Oracle, DevArt.Data.Oracle.Entity, EntityFramework, EntityFramework.SqlServer, paying attention to add the same version as the previous project) but this fails with
An exception of type 'System.Data.Entity.Core.MetadataException' occurred in mscorlib.dll but was not handled in user code

Additional information: Schema specified is not valid. Errors:

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.
The initialisation code looks the same since it has been copied & pasted. I'm running out of ideas....

Re: weird problem in context creation

Posted: Mon 08 Jun 2015 11:28
by Shalex
Please localize the issue (when EF6 provider registration doesn't work) in a separate small test project and send it to us.

Re: weird problem in context creation

Posted: Mon 08 Jun 2015 11:33
by downwind
I'm going to try it. However, as I said, the project is a plug-in in a larger system, and this makes the use of in-code registration strictly required. I can try doing the same in a small application ( hopefully )

Re: weird problem in context creation

Posted: Mon 08 Jun 2015 12:45
by downwind
Ok, test application created. Unfortunately I can't send it following your link: the forum software doesn't recognise my email/password and no password recovery is possible (it says my email address is invalid, even I've received subscription confirmation email at that address, I've opened right now).
How can I do?

Re: weird problem in context creation

Posted: Mon 08 Jun 2015 13:07
by Shalex
1. Different accounts are used for these two resources, and you cannot access one of these accounts using credentials for another one:
http://www.devart.com/
http://forums.devart.com/

2. If your attachment is bigger than 2 MB, we can provide you access to our ftp server.

Re: weird problem in context creation

Posted: Tue 09 Jun 2015 07:59
by downwind
Ok, I've sent all, I think you've got it.
Thanks for your support

Re: weird problem in context creation

Posted: Tue 09 Jun 2015 12:27
by downwind
Sorry disturbing... did you see something odd in my configuration? Something explaining why it works on a project while it fails in another?

Re: weird problem in context creation

Posted: Thu 11 Jun 2015 09:43
by Shalex
downwind wrote:the use of in-code registration strictly required [...]
did you see something odd in my configuration?
Why don't you add the EF provider registration via the code like we described to you at http://forums.devart.com/viewtopic.php? ... 99#p109575?

For example, add this line

Code: Select all

System.Data.Entity.DbConfiguration.SetConfiguration(new Devart.Data.Oracle.Entity.OracleEntityProviderServicesConfiguration());
in the L2SmpQuery constructor in your \WindowsFormsApplication1\Form1.cs. This should fix the "No Entity Framework provider found for the ADO.NET provider with invariant name 'Devart.Data.Oracle'." error.

Re: weird problem in context creation

Posted: Wed 17 Jun 2015 16:55
by downwind
Great! It works!

thanks a lot