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,
I am using these packages in my .Net Core 8project :
Microsoft.EntityFrameworkCore 8.0.2
Npgsql 8.0.2
Npgsql.EntityFrameworkCore.PostgreSQL 8.0.2
EFCore.NamingConventions 8.0.3
My DBContext looks like this : services.AddDbContext<MyDbContext>( options => options.UseNpgsql(connectionStrings.ReadOnlyConnectionString) .UseSnakeCaseNamingConvention() .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
When I am trying to map the jsonb[] (jsonb Array) using OwnsMany it's throwing error. I have added the mapping like this in the OnModelCreating : builder.Entity<SomeEntity>() .OwnsMany(auth => auth.AllContent, d => { d.ToJson("all_content"); });
I have defined my POCO class as :
public class SomeEntity
{
public List<SomeContent> AllContent { get; set; } = [];
}
public class SomeContent {
[JsonPropertyName("guid")]
public string Id { get; set; }
[JsonPropertyName("content_type")]
public string ContentType { get; set; }
[JsonPropertyName("status")]
public string Status { get; set; }
}
When I am trying to access my Entity I am getting error : "Reading as 'System.String' is not supported for fields having DataTypeName 'jsonb[]'\nType 'String' required dynamic JSON serialization, which requires an explicit opt-in; call 'EnableDynamicJson' on 'NpgsqlDataSourceBuilder' or NpgsqlConnection.GlobalTypeMapper (see https://www.npgsql.org/doc/types/json.html and the 8.0 release notes for more details). Alternatively, if you meant to use Newtonsoft JSON.NET instead of System.Text.Json, call UseJsonNet() instead."
Is jsob[] supported currently if yes Please suggest how to access jsonb[] or am I missing something. Thanks in Advance.
The text was updated successfully, but these errors were encountered:
Hi,
I am using these packages in my .Net Core 8project :
My DBContext looks like this :
services.AddDbContext<MyDbContext>( options => options.UseNpgsql(connectionStrings.ReadOnlyConnectionString) .UseSnakeCaseNamingConvention() .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
When I am trying to map the jsonb[] (jsonb Array) using OwnsMany it's throwing error. I have added the mapping like this in the OnModelCreating :
builder.Entity<SomeEntity>() .OwnsMany(auth => auth.AllContent, d => { d.ToJson("all_content"); });
I have defined my POCO class as :
When I am trying to access my Entity I am getting error : "Reading as 'System.String' is not supported for fields having DataTypeName 'jsonb[]'\nType 'String' required dynamic JSON serialization, which requires an explicit opt-in; call 'EnableDynamicJson' on 'NpgsqlDataSourceBuilder' or NpgsqlConnection.GlobalTypeMapper (see https://www.npgsql.org/doc/types/json.html and the 8.0 release notes for more details). Alternatively, if you meant to use Newtonsoft JSON.NET instead of System.Text.Json, call UseJsonNet() instead."
Is jsob[] supported currently if yes Please suggest how to access jsonb[] or am I missing something. Thanks in Advance.
The text was updated successfully, but these errors were encountered: