Comments (7)
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.
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.
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.
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.
@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, 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.
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)
- [Single case DUs] The binary operator Equal is not defined for the types `UserId` and `UserId` HOT 1
- DbContextHelpers.fs methods return type obj instead of 'a HOT 1
- [Option] Optional DateTime properties cannot be filtered HOT 1
- Migration not generated due to optional single case DU HOT 1
- How do you create an optional navigation property? HOT 3
- Scaffolding fails if a column uses a DEFAULT value
- singleCaseUnionMemberTranslator Translate should return null for non-applicable expressions
- Support for empty discriminated union HOT 2
- Documentation: Guide on how to create a many-to-many relationships HOT 2
- When trying to call registerSingleCaseUnionTypes from C#, I get an InvalidOperationException
- NullReferenceException on second migration HOT 1
- The Getting Started guide does not work well HOT 3
- NullReferenceException when deleting optional fields
- Support EF Core 7 HOT 1
- Scaffolding a `nvarchar NULL` creates a `string` and not a `string option`
- Nullpointer on second migration when having a string option field
- Extension UseFsharpTypes() interferes with the npgsql translation for where statement on jsonb columns
- Subsequent migrations fail with `type 'JsonDocument' is not defined` error for JSONB column HOT 3
- Npgsql JSONB to POCO mapping produces an empty `open` stmt in `Migration/*Snapshot.fs`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efcore.fsharp.