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
publicclassTestEntity{publicintId{get;set;}publicstringTitle{get;set;}publicList<Blog>Blogs{get;set;}}publicclassBlog{publicstringTitle{get;set;}publicstringContent{get;set;}}publicclassContext:DbContext{protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){modelBuilder.Entity<TestEntity>(entity =>{entity.OwnsMany(a =>a.Blogs, b =>{b.ToJson().HasColumnType("json");});});base.OnModelCreating(modelBuilder);}}
Migration : Ok (has proper column type)
Insertion : Ok
Querying : System.InvalidOperationException: No coercion operator is defined between types 'System.Text.Json.JsonElement' and 'System.IO.MemoryStream'
When removing the HasColumnType("json").
Both insertion & querying work despite the column being "json" and not "jsonb"
But migrating will change the column to jsonb.
The text was updated successfully, but these errors were encountered:
Confirmed. Simple repro (see below) does not work on SQL Server, so seems like an EFCore.PG issue. Issue to add support for HasColumnType() in EF is dotnet/efcore#28452.
I looked at this, and unfortunately it's not going to be possible to support json owned mapping before dotnet/efcore#32192 is fixed on the EF side (even the jsonb support is quite hacky because of that). I'll tentatively put this in the 10 milestone, with the hope that it gets fixed on the EF side.
EntityFramework.Core : 9.0.2,
Npgsql.EntityFrameworkCore : 9.0.3
Migration : Ok (has proper column type)
Insertion : Ok
Querying : System.InvalidOperationException: No coercion operator is defined between types 'System.Text.Json.JsonElement' and 'System.IO.MemoryStream'
When removing the HasColumnType("json").
Both insertion & querying work despite the column being "json" and not "jsonb"
But migrating will change the column to jsonb.
The text was updated successfully, but these errors were encountered: