npgsql, EF - "Update Database from Model" issue

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
ADO_kg
Posts: 1
Joined: Sun 24 May 2015 11:40

npgsql, EF - "Update Database from Model" issue

Post by ADO_kg » Sun 24 May 2015 11:57

I am using Visual Studio 2013, Postgresql 9.4.

I want to create a Model First. For that created an empty project and added "ADO.NET Entity Data Model", "Empty EF Designer model". Added tables and want to "Generate Database from Model", but having the following error during Build:
Error 1 Running transformation: System.InvalidOperationException: The SSDL generated by the activity called 'CsdlToSsdlAndMslActivity' is not valid and has the following errors: No Entity Framework provider found for the ADO.NET provider with invariant name 'Npgsql'. 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.
at Microsoft.Data.Entity.Design.DatabaseGeneration.EdmExtension.CreateAndValidateStoreItemCollection(String ssdl, Version targetFrameworkVersion, IDbDependencyResolver resolver, Boolean catchThrowNamingConflicts) at Microsoft.VisualStudio.TextTemplatingBF0D3C22AA28598FCC73795B901067ECB063D68581DCCB368A21EA6F043AE2089B71B51EA9D0340B9B3C9A5B90BC22C74D4C3BBD2BDC480DED3D26F1026A00DC.GeneratedTextTransformation.get_Store() in c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\GenerateTSQL.Utility.ttinclude:line 57 at Microsoft.VisualStudio.TextTemplatingBF0D3C22AA28598FCC73795B901067ECB063D68581DCCB368A21EA6F043AE2089B71B51EA9D0340B9B3C9A5B90BC22C74D4C3BBD2BDC480DED3D26F1026A00DC.GeneratedTextTransformation.TransformText() in c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen\SSDLToSQL10.tt:line 84 c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\GenerateTSQL.Utility.ttinclude 57 1
But even though I am able to fetch tables from Database - "Update Model from Database". It adds tables from Database to Model, but reverse is not working with above error.

I do not how to put image here, here is a link:
https://www.dropbox.com/s/gna5h091j5loo ... 4.png?dl=0

Here is my App.config

Code: Select all

<?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>

  <entityFramework>
    <defaultConnectionFactory type="Npgsql.NpgsqlFactory, Npgsql" />
    <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </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>

<connectionStrings>
  <add name="DefaultConnection" 
       providerName="Npgsql" 
       connectionString="server=127.0.0.1;userid=postgres;password=root;database=nagin" />
</connectionStrings>
</configuration>
I use last versions of Entity Framework 6.1.3 and Npgsql 2.2.5.0 Npgsql is registered in GAC - Setup_Npgsql-2.2.5.0-r3-net45.exe and copied to project reference same dll files.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: npgsql, EF - "Update Database from Model" issue

Post by Shalex » Mon 25 May 2015 12:40

The ADO.NET provider developed by our company is dotConnect for PostgreSQL (Devart.Data.PostgreSql). The following information is about our product.

With EDM Designer, you should add registration of EF6-provider in your app.config manually and rebuild the project before running the wizard (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.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity, Version=7.3.407.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
  </entityFramework>
  <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=7.3.407.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
</configuration>
Replace 7.3.407 here with your current version of dotConnect for PostgreSQL. Please note that the revision number of provider in the entityFramework section is *.6 but it should be *.0 in DbProviderFactories.

We recommend you to use Entity Developer (Devart Entity Model, *.edml) instead of EDM Designer (ADO.NET Entity Data Model, *.edmx) because it is adjusted for working with PostgreSQL and has an advanced functionality: http://www.devart.com/entitydeveloper/ed-vs-edm.html. Additionally, Entity Developer adds registration of EF6-provider in app.config automatically.

Post Reply