question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help with enums and PostgreSQL on Amazon RDS with Encryption

See original GitHub issue

HI

This is not a problem with the library but I wanted to ask because we cant find any documentation and we hope you can point us at the right direction.

We are using Npgsql.EntityFrameworkCore.PostgreSQL Version=2.1.2, we mapped our enumerations correctly and we were working great, but yesterday our security team asked us to enable Encryption on the database, after that we started seeing errors like “The CLR enum type CountryType must be registered with Npgsql before usage”.

In our script we create enums like this:

CREATE TYPE entity_country_type	AS	enum	('CITIZENSHIP','RESIDENCE','TAXATION','NATIONALITY','DOMICILE','BIRTH');

And we have this in code:

NpgsqlConnection.GlobalTypeMapper.MapEnum<CountryType>("entity_country_type"); 
 modelBuilder.ForNpgsqlHasEnum("entity_country_type", new[] { "CITIZENSHIP", "RESIDENCE", "TAXATION", "NATIONALITY", "DOMICILE", "BIRTH" });
public enum CountryType
{
    [PgName("CITIZENSHIP")]
    Citizenship = 0,
    [PgName("RESIDENCE")]
    Residence = 1,
    [PgName("TAXATION")]
    Taxation = 2,
    [PgName("NATIONALITY")]
    Nationality = 3,
    [PgName("DOMICILE")]
    Domicile = 4,
    [PgName("BIRTH")]
    Birth = 5,
}

Are you aware of any changes we have to make to ensure the enum mapping keeps working after we enable the ecryption?

Thanks a lot

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
austindrenskicommented, Jan 22, 2019

@JuanZamudioGBM Thanks for keeping us updated. At this point, it sounds like this isn’t primarily driven by the EF Core provider, so I’m going to close the issue for now.

That said, I would be very interested to hear any resolution details you can share with us. Also, if further investigation does point back to the EF Core provider, we can reopen this issue at that time.

0reactions
JuanZamudioGBMcommented, Jan 22, 2019

Hi

We found the origin of the problem, we are using flyway to handle the changes in the database, and when we add a new version of the script flyway runs with the following commands:

- flyway baseline
- flyway migrate

And the scripts are numbered like this:

V1_0_1__xxxx
V1_0_2__xxxx
V1_0_3__xxxx
V1_0_4__xxxx
V2_0_1__xxxx

After that we see the enum error, we are currently investigating if the new version number is what creates the problem or if simple the fact that adding a new script, and trying to see the logs to see what changes flyway makes in the database so the enum mapping stops working.

Thanks for your time

Read more comments on GitHub >

github_iconTop Results From Across the Web

Encrypt an existing Amazon RDS for PostgreSQL DB ...
This pattern explains how to encrypt an existing Amazon Relational Database Service (Amazon RDS) for PostgreSQL DB instance in the Amazon Web Services...
Read more >
Enable encrypted connections for PostgreSQL DB ...
This pattern describes how you can enable encrypted connections for an Amazon RDS for PostgreSQL DB instance. You can use the same process...
Read more >
Using a PostgreSQL database as an AWS DMS source
Use a PostgreSQL database as a source for AWS DMS. ... You can use Secure Socket Layers (SSL) to encrypt connections between your...
Read more >
Encrypting Amazon RDS resources - AWS Documentation
Amazon RDS can encrypt your Amazon RDS DB instances. Data that is encrypted at rest includes the underlying storage for DB instances, its...
Read more >
Encrypt Amazon RDS for PostgreSQL and Amazon Aurora ...
Converting an unencrypted RDS for PostgreSQL or Amazon Aurora ... In this post, you use the AWS managed default RDS encryption key (alias ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found