You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that I'm doing something wrong but I can't realize what.
I have scaffolded DB with a bunch of enums and one composite type.
In Startup.cs I have:
vardataSourceBuilder=newNpgsqlDataSourceBuilder(connectionString);dataSourceBuilder.EnableUnmappedTypes();dataSourceBuilder.MapComposite<Dimension>("main.dimension");vardataSource=dataSourceBuilder.Build();services.AddDbContext<KsDbContext>(options =>{options.UseNpgsql(dataSource,
o =>{o.MapEnum<AssignmentState>("assignmentstate","operation",newNpgsqlNullNameTranslator());o.MapEnum<Rowstate>("rowstate","main",newNpgsqlNullNameTranslator());
...
When I remove EnableUnmappedTypes, I receive an error: Reading as 'MesOps.AppServer.Enums.Rowstate' is not supported for fields having DataTypeName 'main.rowstate' - System.NotSupportedException: Reading and writing unmapped enums requires an explicit opt-in; call 'EnableUnmappedTypes' on 'NpgsqlDataSourceBuilder' or NpgsqlConnection.GlobalTypeMapper
I think, that I'm mapping columns incorrect. But I can't understand what exactly...
NpgSql - v. 9.0.2
.NET 9.0
The text was updated successfully, but these errors were encountered:
You shouldn't be using EnableUnmappedTypes() for enums when using EF - that option is needed only when using Npgsql without EF, and wanting to not pre-map your enums in advance (e.g. for various dynamic scenarios).
Give the enum mapping docs a good read - as you'er using EF 9, I'd recommend simply using the new ConfigureDataSource() API, which is the easiest way to get things running.
Note that the EF provider doesn't support composite types (#22 tracks that).
If you're still having trouble after following the documentation, please post a minimal, runnable repro. In the meantime, I'll go ahead and close this as a usage issue, but feel free to post back here if you're still encountering issues.
I think that I'm doing something wrong but I can't realize what.
I have scaffolded DB with a bunch of enums and one composite type.
In Startup.cs I have:
In DBContext.cs:
When I remove EnableUnmappedTypes, I receive an error:
Reading as 'MesOps.AppServer.Enums.Rowstate' is not supported for fields having DataTypeName 'main.rowstate' - System.NotSupportedException: Reading and writing unmapped enums requires an explicit opt-in; call 'EnableUnmappedTypes' on 'NpgsqlDataSourceBuilder' or NpgsqlConnection.GlobalTypeMapper
I think, that I'm mapping columns incorrect. But I can't understand what exactly...
NpgSql - v. 9.0.2
.NET 9.0
The text was updated successfully, but these errors were encountered: