npgsql / efcore.pg

Entity Framework Core provider for PostgreSQL
PostgreSQL License
1.54k stars 226 forks source link

Support enums in scaffolding #2517

Open roji opened 2 years ago

roji commented 2 years ago

Enum columns currently aren't scaffolded, and cause a "enum column skipped" warning to get logged.

If the user does the appropriate Npgsql enum mappings beforehand (via data source or global), we should be able to do this. If a mapping isn't present, then rather than emitting a warning we can just do the default int mapping as e.g. SQL Server does; but possibly still do a warning to make users aware of native PG enums.

roji commented 2 years ago

If a mapping isn't present, then rather than emitting a warning we can just do the default int mapping as e.g. SQL Server does

This doesn't work - a native PG enum cannot be mapped to a CLR int. We can possibly map it to a string (ADO unmapped enum mapping), but I wonder how useful that is. But we can lookup into picking up any existing mappings.