Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save raspi/8927531 to your computer and use it in GitHub Desktop.
Save raspi/8927531 to your computer and use it in GitHub Desktop.
Web.config example Entity Framework 6 & Npgsql.EntityFramework (PostgreSQL)
<?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, Culture=neutral" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Html" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider"
invariant="Npgsql"
description ="Data Provider for PostgreSQL"
type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="Context"
connectionString="Server=127.0.0.1;port=5432;Database=test;User Id=test;Password=test1234;"
providerName="Npgsql" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="Npgsql"
type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
</configuration>
@ilkerEker
Copy link

I have used the order 1-system.data,2-ConnectionString,3-entityFrameWork and solve my problem which gives message "ArgumentException: The ADO.NET provider with invariant name 'Npgsql' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details." Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment