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
In npgsql/npgsql@a9401b1 I added composite type support, but since then EFCore changed things in a way that breaks it. It appears that the composite type is now picked up as a navigation property - this makes sense but find a way to make EFCore treat it as scalar?
Reacted by Markus Schaber, Makla, Rodion Mostovoi, Adrian Ordonez, fernacolo, Schmitt Christian, Octavio, Twenty, Yannick Beauchamp-H, Shimmy Weitzhandler and 68 more
It's probably a good idea to wait and get some clarity on dotnet/efcore#246 before implementing this. Otherwise we may end up with something in Npgsql that isn't compatible with whatever the EF team decide to do with complex/value objects.
That mainly means that it's not going to happen for 9.0, not necessarily that it'll happen in 10. On the EF side, there are plans for improving the complex type mapping support, which may make the possible PG composite type support much better/more feasible.
What's the state of the feature currently? Do we have something to help testing? A quick search for "ComplexType" in the code reveals quite a lot of things, but it's unclear how finished they are.
It's important for me because just the other day I was told on /dotnet/efcore that they are pushing to make complex types supersede owned types, and because I look forward to utilizing JSON columns instead of the many helper tables to store collections of owned (future complex) types.
@ZzZombo this isn't implemented yet (open and in the backlog). But it's very important to understand what this is about: it's about allowing to map .NET POCOs to PostgreSQL composite types, which are a PostgreSQL-specific feature involving custom user-defined types in the database. Mapping .NET POCOs to JSON (on PostgreSQL and any other database) is tracked by dotnet/efcore#31252 on the EF side, and has nothing to do with this issue or PostgreSQL composite types (there are pros and cons of mapping to JSON vs. composite types - they're two different mapping strategieS).
In any case, composite mapping is definitely something I want to do, but is far from trivial. However, the work on the EF side to enable complex type JSON mapping should provide some important infrastructure for doing composite mapping here as well.
@sergeidorodnov as always with issues in the backlog, I can't say whether it will be implemented in the future or not. This issue hasn't exactly received a huge number of votes, it's quite complex to implement and there are many other competing priorities. That's really all I can say at the moment.
@roji hey, I currently use raw sql for a project with a lot of denormalization and we decided to use composite types and arrays of composite types. We would have loved to be able to use ef core for this project
Activity
roji commentedon Jul 30, 2016
It's probably a good idea to wait and get some clarity on dotnet/efcore#246 before implementing this. Otherwise we may end up with something in Npgsql that isn't compatible with whatever the EF team decide to do with complex/value objects.
roji commentedon Oct 25, 2016
Note: in addition to the actual mapping of the composite type, there's the question of support for creating the PostgreSQL type (i.e. CREATE TYPE).
xumix commentedon Jan 31, 2018
Looks like ef core has closed #246
59 remaining items
roji commentedon Nov 24, 2023
pm64 commentedon Oct 20, 2024
Hey @roji, I noticed this was moved from 9.0.0 to Backlog. Does that mean you're potentially planning it for 10.0?
Huge fan, thanks for all you do.
roji commentedon Oct 20, 2024
That mainly means that it's not going to happen for 9.0, not necessarily that it'll happen in 10. On the EF side, there are plans for improving the complex type mapping support, which may make the possible PG composite type support much better/more feasible.
ZzZombo commentedon Nov 22, 2024
What's the state of the feature currently? Do we have something to help testing? A quick search for "ComplexType" in the code reveals quite a lot of things, but it's unclear how finished they are.
It's important for me because just the other day I was told on /dotnet/efcore that they are pushing to make complex types supersede owned types, and because I look forward to utilizing JSON columns instead of the many helper tables to store collections of owned (future complex) types.
roji commentedon Nov 22, 2024
@ZzZombo this isn't implemented yet (open and in the backlog). But it's very important to understand what this is about: it's about allowing to map .NET POCOs to PostgreSQL composite types, which are a PostgreSQL-specific feature involving custom user-defined types in the database. Mapping .NET POCOs to JSON (on PostgreSQL and any other database) is tracked by dotnet/efcore#31252 on the EF side, and has nothing to do with this issue or PostgreSQL composite types (there are pros and cons of mapping to JSON vs. composite types - they're two different mapping strategieS).
In any case, composite mapping is definitely something I want to do, but is far from trivial. However, the work on the EF side to enable complex type JSON mapping should provide some important infrastructure for doing composite mapping here as well.
[-]Composite support[/-][+]PostgreSQL composite type support[/+]sergeidorodnov commentedon Jul 8, 2025
I would like to know if support for composite types will be implemented? It has been more than 9 years since the first post in this thread.
roji commentedon Jul 9, 2025
@sergeidorodnov as always with issues in the backlog, I can't say whether it will be implemented in the future or not. This issue hasn't exactly received a huge number of votes, it's quite complex to implement and there are many other competing priorities. That's really all I can say at the moment.
Geosecure-Australia commentedon Dec 3, 2025
OMG. I spent hours trying to get this to work, and it can't! ARRRRGG!
ctigrisht commentedon Mar 21, 2026
@roji hey, I currently use raw sql for a project with a lot of denormalization and we decided to use composite types and arrays of composite types. We would have loved to be able to use ef core for this project
roji commentedon Mar 22, 2026
FYI there are some changes planned on the EF side that should make composite support easier, but it will still be a while before this can happen.