Darion Badlydone
Darion Badlydone

Reputation: 947

npgsql 2.1.3 and EF 6: Could not determine storage version; a valid storage connection or a version hint is required

I'm adding the support to EF 6 to my sql generator for PostgreSQL: PostgreSQL Migration Generator

I have created a test project to try it but when I create a new connection return new NpgsqlConnection();, it throw this exception to me:

An exception of type 'System.NotSupportedException' occurred in EntityFramework.dll but was not handled in user code

Additional information: Unable to determine the provider name for provider factory of type 'Npgsql.NpgsqlFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.

Follow the instruction found in the Npgsql official site, I use this app.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework"></provider>
    </providers>
    <defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql" />
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Npgsql" />
      <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
    </DbProviderFactories>
  </system.data>
</configuration>

I don't understand why this exception is fired up. I have tried a lot of configuration but anyone works.

Upvotes: 1

Views: 9207

Answers (4)

xyz737636
xyz737636

Reputation: 1

delete the __MigrationHistory table if you are using code first and generating database using migration

Upvotes: -1

raptor
raptor

Reputation: 23

Installing Entity Framework 6 Tools will solve your problem.

Cheers.

Upvotes: 0

idanek
idanek

Reputation: 39

For MVC application inside Global.asax in method Application_Start() at the end I put line:

Database.SetInitializer(null);

This solved same problem.

Upvotes: 0

Vincenzo Costa
Vincenzo Costa

Reputation: 960

Solution Explorer

  1. Right click over file .edmx
  2. Open with..
  3. Editor XML
  4. Change ProviderManifestToken="XXXX" with 2008

Upvotes: 19

Related Questions