From 63b8d82069885bd53820ae5a85ff794c9f5ec34d Mon Sep 17 00:00:00 2001 From: Dillan Cagnetta Date: Tue, 27 Aug 2019 11:20:10 +0200 Subject: [PATCH] Added: postgreSQL documentation --- docs/en/Best-Practices/Index.md | 1 + .../Best-Practices/PostgreSQL-Integration.md | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 docs/en/Best-Practices/PostgreSQL-Integration.md diff --git a/docs/en/Best-Practices/Index.md b/docs/en/Best-Practices/Index.md index 93d6409909..68d8d98d53 100644 --- a/docs/en/Best-Practices/Index.md +++ b/docs/en/Best-Practices/Index.md @@ -24,4 +24,5 @@ Also, this guide is mostly usable for general **application development**. * Data Access * [Entity Framework Core Integration](Entity-Framework-Core-Integration.md) * [MongoDB Integration](MongoDB-Integration.md) + * [PostgreSQL Integration](PostgreSQL-Integration.md) diff --git a/docs/en/Best-Practices/PostgreSQL-Integration.md b/docs/en/Best-Practices/PostgreSQL-Integration.md new file mode 100644 index 0000000000..82d3cc9421 --- /dev/null +++ b/docs/en/Best-Practices/PostgreSQL-Integration.md @@ -0,0 +1,61 @@ +## Entity Framework Core PostgreSQL Integration + +> See [Entity Framework Core Integration document](../Entity-Framework-Core.md) for the basics of the EF Core integration. + +### EntityFrameworkCore Project Update + +- In `Acme.BookStore.EntityFrameworkCore` project replace package `Volo.Abp.EntityFrameworkCore.SqlServer` with `Volo.Abp.EntityFrameworkCore.PostgreSql` +- Update to use PostgreSQL in `BookStoreEntityFrameworkCoreModule`. Example: + +````C# +[DependsOn( + //code omitted for brevity + + /* This was updated from AbpEntityFrameworkCoreSqlServerModule */ + typeof(AbpEntityFrameworkCorePostgreSqlModule), + /* This was updated from AbpEntityFrameworkCoreSqlServerModule */ + + //code omitted for brevity + )] +public class Acme.BookStore.EntityFrameworkCoreModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + options.AddDefaultRepositories(includeAllEntities: true); + }); + + Configure(options => + { + /* This was updated */ + options.UsePostgreSql(); + /* This was updated */ + }); + } + } +```` + +### EntityFrameworkCore.DbMigrations Project Update +- **Do** update to use PostgreSQL in `BookStoreMigrationsDbContextModelSnapshot.cs` + +import `Npgsql.EntityFrameworkCore.PostgreSQL.Metadata` by adding + +````C# +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +```` + +replace all references +```` +.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); +```` + + to + +````C# +.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); +```` + +### Update Connection String Settings +> Update the PostgreSQL connection string in all `appsettings.json` files +