I defined the following composite type in my postgre db:
CREATE TYPE foobar AS
(
foo NUMERIC,
bar NUMERIC
);
I have created a struct with the same properties:
public struct FooBar
{
public decimal Foo { get; set; }
public decimal Bar { get; set; }
}
And now I would like to use FooBar as such in an entity:
public class FooyaEntity
{
public Guid Id { get; set; }
public string Name { get; set; }
public FooBar FooBar { get; set; }
}
How would I configure ef core to map these properly? Currently when trying to add something it will yield the following error:
System.InvalidOperationException: The property 'Test.FooBar' could not be mapped, because it is of type 'FooBar' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
Also the documentation for npgsql shows working examples without ef core.
Mapping to PostgreSQL composite types isn't yet supported, this is tracked by this issue. Anyone interested, please go upvote it!