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
Hi, thank you in advance for your time reading this issue!
I noticed that specifying a custom schema name on code first migrations and Mapping enums to Postgres in OnModelCreating it generates a script that ignores the informed schema when applying to columns, therefore it is not respecting the schema boundary!
// in a different assemblynamespaceDomain{publicenumTicketStatus{NotInformed,Opened,Closed,ReOpened,Terminated}}// => Domain.dll//DbContext simplifiedpublicclassAppDbContext:DbContext{staticAppDbContext(){NpgsqlConnection.GlobalTypeMapper.MapEnum<Domain.TicketStatus>();}protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){base.OnModelCreating(modelBuilder);modelBuilder.HasDefaultSchema(nameof(MyApp));modelBuilder.HasPostgresEnum<Domain.TicketStatus>();modelBuilder.ToSnakeCase();<--lib to format to snake_case, commenting this line does not affect the output.//... }}
It generates something like this:
CREATETYPEmyapp.ticket_status AS ENUM ('not_informed', 'opened', 'closed', 're_opened', 'terminated');
ALTERTABLEmyapp.ticket_store ALTER COLUMN status TYPE ticket_status;
I believe the expected behavior should be:
ALTERTABLEmyapp.ticket_store ALTER COLUMN status TYPE myapp.ticket_status;
(Partial) Workaround:
I solved the problem by adding the search path key into my connection string:
Hi, thank you in advance for your time reading this issue!
I noticed that specifying a custom schema name on code first migrations and Mapping enums to Postgres in
OnModelCreating
it generates a script that ignores the informed schema when applying to columns, therefore it is not respecting the schema boundary!It generates something like this:
I believe the expected behavior should be:
(Partial) Workaround:
I solved the problem by adding the
search path
key into my connection string:This was working fine until I needed a different enum/type in other schema inside the same database...
Thanks
The text was updated successfully, but these errors were encountered: