Skip to content

Subsequent migrations fail with type 'JsonDocument' is not defined error for JSONB column #160

@nodakai

Description

@nodakai

Describe the bug

To Reproduce

type Tab = {
  Id: int
  Js: JsonDocument
}
ef migrations add First
ef database update  # works
ef migrations add Second

migrations/20231103200659_Second.fs(502,24): error FS0039: The type 'JsonDocument' is not defined.

which is from this line

            b.Property<JsonDocument>("Js")
                .IsRequired(true)
                .HasColumnType("jsonb")
                |> ignore

without open System.Text.Json

(Additionally, to avoid potential conflicts with user-defined types, wouldn't it be safer for machine-generated files to always use fully qualified type names, prefixed with global, given that one might create an entity named Int?)

Additional context

% dotnet list package
Project 'My.Postgres.Lib' has the following package references
   [net7.0]: 
   Top-level Package                               Requested   Resolved
   > EntityFrameworkCore.FSharp                    6.0.7       6.0.7   
   > FSharp.Core                                   7.0.400     7.0.400 
   > FSharpPlus                                    1.5.0       1.5.0   
   > Microsoft.EntityFrameworkCore.Design          6.0.23      6.0.23  
   > Microsoft.EntityFrameworkCore.Relational      6.0.23      6.0.23  
   > Npgsql.EntityFrameworkCore.PostgreSQL         6.0.22      6.0.22  

Logs above have been extracted from our proprietary codebase and edited to omit certain confidential details, are not from a minimal, self-contained repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions