Page 1 of 1

MetadataException

Posted: Thu 14 Feb 2013 14:13
by Oleg Mikhaylov
There was topic about similar issue at http://forums.devart.com/viewtopic.php?f=30&t=25699, in that case error was caused by configuration. But in my case similar error appears with correct configuration, I think after recent EF6 NuGet package update (MS updated it today).

I checked configuration, it looks ok, assembly versions have 6 at the end like in that discussion:

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>
  
  <connectionStrings>
    <add name="TestEntitiesConnectionString" connectionString="metadata=TestModel.csdl|TestModel.ssdl|TestModel.msl;provider=Devart.Data.PostgreSql;provider connection string="User Id=postgres;Password=123456;Host=localhost;Database=test;Persist Security Info=True;Schema=public"" providerName="System.Data.EntityClient" />
  </connectionStrings>

  <system.data>
    <DbProviderFactories>
      <remove invariant="Devart.Data.PostgreSql"/>
      <add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version=6.4.164.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
    </DbProviderFactories>
  </system.data>

  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity, Version=6.4.164.6, Culture=neutral, PublicKeyToken=09af7300eec23701">
        <migrationSqlGenerator type="Devart.Data.PostgreSql.Entity.Migrations.PgSqlEntityMigrationSqlGenerator, Devart.Data.PostgreSql.Entity, Version=6.4.164.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
      </provider>
    </providers>
  </entityFramework>  
  
</configuration>
Exception is following:
Schema specified is not valid. Errors:
TestModel.ssdl(2,2) : error 0152: The 'Instance' member of the Entity Framework provider type 'Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity, Version=6.4.164.6, Culture=neutral, PublicKeyToken=09af7300eec23701' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must extend from this class and the 'Instance' member must return the Singleton instance of the provider.
Could you please make quick test to ensure is it provider or my issue?

Re: MetadataException

Posted: Fri 15 Feb 2013 16:47
by Shalex
We cannot reproduce the problem with dotConnect for PostgreSQL v 6.4.179 and EntityFramework.dll v 6.0.20214.0. Please do the following:
1. Set a break point in the code, navigate to Debug > Windows > Modules, and make sure that Devart.Data.PostgreSql.Entity.dll with the revision number 6 (e.g.: 6.4.164.6) is loaded in the process of your application.
2. Upgrade to the 6.4.179 version of dotConnect for PostgreSQL.

Re: MetadataException

Posted: Mon 18 Feb 2013 10:00
by Shalex
The possible reason of the problem in your environment.
You have installed dotConnect for PostgreSQL v 6.4.164 and configured your application for using it. Then upgraded the provider to the 6.4.179 version but the configuration (in *.config) was not updated. If this is not the case, make sure that only one Devart.Data.PostgreSql.Entity.dll assembly (of the 6.4.164.6 version) is loaded in the process of your application (assuming that dotConnect for PostgreSQL v 6.4.164 is installed on your workstation).

Re: MetadataException

Posted: Tue 19 Feb 2013 13:44
by Oleg Mikhaylov
Thanks!

It really was an error with old version stucked in GAC.