Npgsql JSONB to POCO mapping produces an empty `open` stmt in `Migration/*Snapshot.fs`
Opened this issue · 0 comments
Split from #160 (comment)
Describe the bug
When utilizing Npgsql's JSONB to POCO mapping, Migrations/*Snapshot.fs
gets emitted with an empty, malformed open
statement:
open System
open System.Text.Json
open
open Microsoft.EntityFrameworkCore
open Microsoft.EntityFrameworkCore.Infrastructure
open Microsoft.EntityFrameworkCore.Metadata
open Microsoft.EntityFrameworkCore.Migrations
open Microsoft.EntityFrameworkCore.Storage.ValueConversion
open Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
To Reproduce
I think this mode of utilizing JSON columns, which I started exploring recently, produces an empty open
statement
https://www.npgsql.org/efcore/mapping/json.html#poco-mapping
public class SomeEntity
{
public int Id { get; set; }
[Column(TypeName = "jsonb")]
public Customer Customer { get; set; }
}
public class Customer // Mapped to a JSON column in the table
{
public string Name { get; set; }
public int Age { get; set; }
public Order[] Orders { get; set; }
}
That is, with Npgsql, using [Column(TypeName = "jsonb")]
enables an arbitrary type (e.g., Customer
) to be included as part of an entity (e.g., SomeEntity
), without the need to register the former as an entity using DbSet
. I can imagine this being a tricky corner case for the migration builder.
Expected behavior
open System
open System.Text.Json
open Microsoft.EntityFrameworkCore
open Microsoft.EntityFrameworkCore.Infrastructure
open Microsoft.EntityFrameworkCore.Metadata
open Microsoft.EntityFrameworkCore.Migrations
open Microsoft.EntityFrameworkCore.Storage.ValueConversion
open Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
Desktop (please complete the following information):
dotnet list package
Project 'EfPostgresPotionalFk' has the following package references
[net7.0]:
Top-level Package Requested Resolved
> EntityFrameworkCore.FSharp 6.0.7 6.0.7
> FSharp.Core 7.0.402 7.0.402
> FSharpPlus 1.5.0 1.5.0
> Microsoft.EntityFrameworkCore.Design 6.0.25 6.0.25
> Npgsql.EntityFrameworkCore.PostgreSQL 6.0.22 6.0.22
Additional context
If I just remove the empty open
statement, the project seems to compile and work as expected, so this issue isn't a real show stopper for me