Source generator that generates code used to register and map enums to NpgSQL
Caution
Superseded by https://github.com/Atulin/NpgsqlSourceGenerators
- Add the
[NpgsqlEnum]
attribute to selected enums
[NpgsqlEnum]
enum Animals
{
Cat,
Dog,
Parrot,
Tardigrade
}
- Call
MapPostgresEnums()
onNpgsqlConnection.GlobalTypeMapper
public MyDbContext(DbContextOptions options) : base(options)
{
NpgsqlConnection.GlobalTypeMapper.MapPostgresEnums(); 👈
}
- Call
RegisterPostgresEnums()
on yourModelBuilder
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.RegisterPostgresEnums(); 👈
}