-
Notifications
You must be signed in to change notification settings - Fork 6k
Replace deprecated type provider with Entity Framework Core in F# query expressions documentation #48751
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
Replace deprecated type provider with Entity Framework Core in F# query expressions documentation #48751
Conversation
Co-authored-by: BillWagner <[email protected]>
…losure Co-authored-by: BillWagner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot You need to fix the build errors.
samples/snippets/fsharp/query-expressions/query-expressions.fsproj
Outdated
Show resolved
Hide resolved
…rent project Co-authored-by: BillWagner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few things to address here @copilot
Co-authored-by: BillWagner <[email protected]>
Tagging @T-Gro for review, even in draft status. Is the new sample idiomatic F#? It looks more like C# translated to F#, but in this area, they can be quite similar. |
@copilot : I disagree with the motivation. The example should show that. F# has strong combinators for in-memory data (List,Array,Seq,..) and there is no added value in using queries for that. THe original set of samples usign |
Co-authored-by: T-Gro <[email protected]>
I understand your concern. The original examples with What would you prefer for a modern alternative that maintains the database context? Options could be:
Which approach would best serve developers learning F# query expressions? |
@copilot : Use EFCore |
Co-authored-by: T-Gro <[email protected]>
Implemented Entity Framework Core examples as requested. The snippets now use proper DbContext classes with EF Core 9.0, demonstrating real database querying patterns. The examples use the in-memory database provider for demonstration purposes, but the same query syntax works with any EF Core provider (SQL Server, PostgreSQL, etc.). This properly shows the purpose of F# query expressions - querying databases, not in-memory collections. Commit: d1680c7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM now as well.
Thanks @T-Gro
Replace Deprecated Type Provider with Entity Framework Core in Query Expressions Documentation
The type provider example in F# query expressions documentation is using deprecated
FSharp.Data.TypeProviders
which is not compatible with modern .NET versions (net5.0+). This PR replaces it with Entity Framework Core, which demonstrates real database querying - the intended purpose of F# query expressions.Changes Made
1. Project Structure
fssamples.fsproj
to use correct SDK (Microsoft.NET.Sdk
)/samples/snippets/fsharp/query-expressions/query-expressions.fsproj
Microsoft.EntityFrameworkCore
(9.0.0)Microsoft.EntityFrameworkCore.InMemory
(9.0.0)2. Entity Framework Core Implementation
SqlDataConnection
type provider with proper EF Core DbContext classesSchoolContext
andNorthwindContext
using EF Core patternsStudent
,Course
,CourseSelection
) with[<CLIMutable>]
attributeNullable<T>
for nullable fields (standard EF Core pattern)db.Student
,db.Course
,db.CourseSelection
pattern3. Documentation Updates
query-expressions.md
to use:::code language="fsharp" source="...":::
syntax for external snippets09/26/2025
db.Student
syntax throughout (no unnecessary renaming)4. Why Entity Framework Core?
Query expressions in F# are designed for querying databases (RDBMS), not in-memory collections. F# already has strong combinators (List, Array, Seq modules) for in-memory data. The original examples with deprecated type providers correctly demonstrated database querying; this PR modernizes that approach using EF Core, which is:
Testing & Validation
db.Student
pattern matches EF Core usageImpact
Fixes #22206
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Internal previews