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

AlterColumn operations included in what should be an empty migration #126

Closed
simon-reynolds opened this issue Nov 30, 2021 · 0 comments · Fixed by #133
Closed

AlterColumn operations included in what should be an empty migration #126

simon-reynolds opened this issue Nov 30, 2021 · 0 comments · Fixed by #133
Assignees

Comments

@simon-reynolds
Copy link
Collaborator

A migration with no changes from the last should have no operations

Given the following context, add two migrations

namespace Test

open System
open System.Collections.Generic
open Microsoft.EntityFrameworkCore
open Microsoft.EntityFrameworkCore.Design
open Microsoft.EntityFrameworkCore.Metadata
open Microsoft.EntityFrameworkCore.Metadata.Builders
open EntityFrameworkCore.FSharp.Extensions

module rec Domain =
    [<AllowNullLiteral>]
    type Account() =
        [<DefaultValue>] val mutable private _Id: int
        [<DefaultValue>] val mutable private _CustomerId: int
        [<DefaultValue>] val mutable private _Customer: Customer
        member this.Id with get() = this._Id and set v = this._Id <- v
        member this.CustomerId with get() = this._CustomerId and set v = this._CustomerId <- v
        member this.Customer with get() = this._Customer and set v = this._Customer <- v

    [<AllowNullLiteral>]
    type Customer() =
        [<DefaultValue>] val mutable private _Id: int
        [<DefaultValue>] val mutable private _ProfileId: int
        [<DefaultValue>] val mutable private _Profile: Profile
        [<DefaultValue>] val mutable private _AddressId: int
        [<DefaultValue>] val mutable private _Address: Address
        member this.Id with get() = this._Id and set v = this._Id <- v
        member this.ProfileId with get() = this._ProfileId and set v = this._ProfileId <- v
        member this.Profile with get() = this._Profile and set v = this._Profile <- v
        member this.AddressId with get() = this._AddressId and set v = this._AddressId <- v
        member this.Address with get() = this._Address and set v = this._Address <- v

    [<AllowNullLiteral>]
    type Profile() =
        [<DefaultValue>] val mutable private _Id: int
        member this.Id with get() = this._Id and set v = this._Id <- v

    [<AllowNullLiteral>]
    type Address() =
        [<DefaultValue>] val mutable private _Id: int
        member this.Id with get() = this._Id and set v = this._Id <- v

    type LetsConnectContext() =
        inherit DbContext()

        [<DefaultValue>] val mutable private _Accounts : DbSet<Account>
        member this.Accounts with get() = this._Accounts and set v = this._Accounts <- v

        [<DefaultValue>] val mutable private _Customers : DbSet<Customer>
        member this.Customers with get() = this._Customers and set v = this._Customers <- v

        [<DefaultValue>] val mutable private _Profiles : DbSet<Profile>
        member this.Profiles with get() = this._Profiles and set v = this._Profiles <- v

        override _.OnModelCreating builder =
            builder.RegisterOptionTypes() // enables option values for all entities

        override __.OnConfiguring(options: DbContextOptionsBuilder) : unit =
            options.UseSqlServer(Environment.GetEnvironmentVariable("CONNECTION_STRING")) |> ignore

Expected behavior
Second migration should be empty. Instead there are AlterColumn operations created for each Primary and Foreign Key

(Originally reported as part of #124 by @LiteracyFanatic )

@simon-reynolds simon-reynolds self-assigned this Nov 30, 2021
simon-reynolds added a commit that referenced this issue Nov 30, 2021
## [6.0.5] - 2021-11-30

### Fixed
- AlterColumn operations no longer emit compiler warnings - #125

### Known Issues
- AlterColumn operations are being created in what should be empty migrations. No effect on functionality but shouldn't be happening - associated issue - #126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant