Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Npgsql JSONB to POCO mapping produces an empty open stmt in Migration/*Snapshot.fs #161

Open
nodakai opened this issue Nov 16, 2023 · 0 comments

Comments

@nodakai
Copy link

nodakai commented Nov 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant