Giter Club home page Giter Club logo

Comments (7)

bricelam avatar bricelam commented on June 2, 2024 1

Hmm, it feels like this shouldn't be needed in the differ. An F#-specific model building convention should mark the IColumn as IsNullable when the CLR type uses option.

/cc @AndriySvyryd

from efcore.fsharp.

simon-reynolds avatar simon-reynolds commented on June 2, 2024

Hi @GunnerGuyven
So Migration 4 is failing even though it has no changes compared to 3? So 4 should just be an empty migration?

Sounds like it could be related to Pomelo if it works with Microsoft.EntityFrameworkCore.Sqlite, I notice the stacktrace doesn't mention this projects override of the ModelDiffer, EntityFrameworkCore.FSharp.Migrations.Internal. FSharpMigrationsModelDiffer

@bricelam, quick question, in IDesignTimeServices.ConfigureDesignTimeServices we call services.AddSingleton<IMigrationsModelDiffer, FSharpMigrationsModelDiffer>()
If the Pomelo Sqlite connector also overrides IMigrationsModelDiffer would EF just pick up whichever one was registered last?

from efcore.fsharp.

GunnerGuyven avatar GunnerGuyven commented on June 2, 2024

That's right, there is no model change. I have narrowed this issue to the presence of the option type itself in the previous migration. You can construct an elaborate model involving option types and so long as there are no previous migrations (involving option types), the migration will succeed.

from efcore.fsharp.

GunnerGuyven avatar GunnerGuyven commented on June 2, 2024

I have created a project demonstrating this issue

git clone https://github.com/GunnerGuyven/ef-pomelo-fsharp-migrate-failure
cd .\ef-pomelo-fsharp-migrate-failure\
dotnet tool restore
dotnet restore
dotnet ef migrations add test4

And opened a ticket with Pomelo to match this one (PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#1700)

from efcore.fsharp.

GunnerGuyven avatar GunnerGuyven commented on June 2, 2024

@simon-reynolds Researching the codebase of Pomelo, I see that they do indeed also add an IMigrationsModelDiffer to the EF builder. This seems done to handle some MySql specific peculiarities with datetime and timestamp fields in certain situations. Surely there is a way of navigating when two handlers have been registered in this manner by different stakeholders?

If there is a 'good citizen' approach to this problem, what would it be and which library should hold that responsibility?

from efcore.fsharp.

bricelam avatar bricelam commented on June 2, 2024

bricelam, quick question, in IDesignTimeServices.ConfigureDesignTimeServices we call services.AddSingleton<IMigrationsModelDiffer, FSharpMigrationsModelDiffer>()
If the Pomelo Sqlite connector also overrides IMigrationsModelDiffer would EF just pick up whichever one was registered last?

The model differ is not designed to be overridden by providers or extensions. Additional functionality should instead be enabled using model annotations.

This seems done to handle some MySql specific peculiarities with datetime and timestamp fields in certain situations.

I vaguely remember this. I think there's an EF issue to review this code and see if there's anything we can add to make this better.

What functionality is currently added by the F# override? Could it be part of the core EF implementation?

from efcore.fsharp.

simon-reynolds avatar simon-reynolds commented on June 2, 2024

The F# override is to add support for the Option<_> type, it's a wrapper similar to Nullable<_>
F# tries to avoid use of null as much as possible, so it uses the option type instead that wraps an item that may or may not be capable of having a null value

The F# model differ matches conventions by marking every column that isn't a PrimaryKey as non-nullable unless the CLR type is either Nullable<_> or Option<_>
Since Option<_> is F# specific, I don't know if there's appetite in EF Core for including it?

from efcore.fsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.