efcore / EFCore.FSharp

Adds F# design-time support to EF Core
MIT License
234 stars 27 forks source link

Incorrectly generated migration for newly added bool property #138

Closed otsomkalov closed 2 years ago

otsomkalov commented 2 years ago

Hello! I'm using library to manipulate PostgreSQL DB and facing the next issue

Describe the bug Migration created for newly added bool property to the type contains wrong defaultValue

To Reproduce Steps to reproduce the behavior:

  1. Create new F# app
  2. Create a new type:
    type User() =
    member val Id = 0 with get, set
  3. Create DbContext:

    type AppDbContext(opts: DbContextOptions<AppDbContext>) =
    inherit DbContext(opts)
    
    member val Users = base.Set<User>()
  4. Setup app to use Postgre DB
  5. Create new migration -> everthing is fine, migration is correct
  6. Include newly created files from step 5 to the project
  7. Add new field to User type from step 2
    member val Active = false with get, set
  8. Create new migration
  9. Try to apply migration to DB -> fails with message
    Exception data:
    Severity: ERROR
    SqlState: 22P02
    MessageText: invalid input syntax for type boolean: "``false``"
    File: bool.c
    Line: 151
    Routine: boolin
  10. Inspect migration file:
    override this.Up(migrationBuilder:MigrationBuilder) =
        migrationBuilder.AddColumn<bool>(
            name = "Active"
            ,table = "Users"
            ,``type`` = "boolean"
            ,nullable = false
            ,defaultValue = "``false``"
            ) |> ignore

Expected behavior Migration is applied to DB

Additional context Npgsql.EntityFrameworkCore.PostgreSQL v.6.0.4 EntityFrameworkCore.FSharp v.6.0.6

simon-reynolds commented 2 years ago

Hi @otsomkalov I've been unable to reproduce this issue, I have released v6.0.7 in the meantime, would you be able to tell me if this is still an issue for you?

otsomkalov commented 2 years ago

Hey @simon-reynolds I've updated packages in project & also dotnet ef tool and now migration generated corectly. Thanks for the cool library ❤️