Reputation: 947
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
Reputation: 1
delete the __MigrationHistory table if you are using code first and generating database using migration
Upvotes: -1
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
Reputation: 960
Solution Explorer
Upvotes: 19