6

I have spent many hours trying to use PostgreSQL with ASP.NET Boilerplate Core 2.x + Module Zero (which looks awesome!).

  1. I added Npgsql.EntityFrameworkCore.PostgreSQL & Npgsql.EntityFrameworkCore.PostgreSQL.Design dependencies to myApp.EntityFrameworkCore.

  2. I also changed the connection string and I use builder.UseNpgsql instead of builder.UseSqlServer in myappDbContextConfigurer.cs.

As a new project, I started with Npgsql v2.0.0. But after a few problems, I found that this release has some issues. So I returned to the 1.1.1 release.

I'm pretty sure this part works fine. The next step is to delete all existing migrations and reload them:

  • Add-Migration "Initial_Migrations"
  • Add-Migration "AbpZero_Initial"

When I do the first one, I get an error:

Method 'Clone' in type 'Microsoft.EntityFrameworkCore.Infrastructure.Internal.NpgsqlOptionsExtension' from assembly 'Npgsql.EntityFrameworkCore.PostgreSQL, Version=1.1.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' does not have an implementation.

I found a beginning of the solution here (6th post): https://forum.aspnetboilerplate.com/viewtopic.php?t=5304&p=13013

The post seems a little bit outdated and I don't know where to implement NpgsqlMigrationSqlGenerator (I mean, in which project).

Thank you for reading this post, any help will be appreciated.

4
  • Npgsql v1.1.1 targets .NETStandard 1.3, which is incompatible with ABP for .NET Core 2.x. Commented Nov 26, 2017 at 10:31
  • Thank you @aaron :) Commented Nov 26, 2017 at 11:27
  • You're welcome. Does that mean you got it to work with Npgsql v2.0.0? Commented Nov 26, 2017 at 11:30
  • No... I'm still working on it. Commented Nov 26, 2017 at 11:39

1 Answer 1

5

To solve your issue with the Abp Template (v3.4.0 .NET core + mvc + modulezero) you have to :

  • Uninstall the package Microsoft.EntityFrameworkCore.SqlServer
  • add Npgsql.EntityFrameworkCore.PostgreSQL (2.0.0) & Npgsql.EntityFrameworkCore.PostgreSQL.Design (1.1.1)
  • Drop ALL files in the "Migrations" directory (Project "EntityFrameworkCore/Migrations")

There're other minors changes pointed here.

Sign up to request clarification or add additional context in comments.

5 Comments

Member for 2 years and 7 months on SO, with 0 questions and this drew you out to post your first answer? Nice :)
Could you explain why the downgrade is required?
Thank you @GeorgeDuke ! Everything looks good, tables are created and the project compiles. I'm now able to go to the swagger view, even if I still have a warning when I run the migration... An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: 42P01: relationship « AbpEditions » does not exist
@aaron : Thanks. Previously, without this downgrade, i was not able to execute the database migration instructions. But after a new test, this step is not necessary. (My previous answer is updated now)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.