Relational Databases access questions

Hi,

I am new to F# and I am trying to evaluate the best data access method for two web applications:

  • one written in C#, it accesses a SQL Server 2008 database via EF (database first model). I want to transition gradually to F# (re-writing the app in F# is out of the question). I was wondering what would the best way to access the data from the F# code. A project is under way to upgrade to SQL Server 2017 or 2019, so using FSharp.Data.SqlClient would be an option.

  • a hobby project that accesses a small PostgreSql database.

I am a bit overwhelmed by the multitude of choices. I guess F# follows into the footsteps of Microsoft solutions: Linq-to-Sql, EF & Ado.Net.

Here are my questions:

  1. Is FSharp.Data.SqlClient an actively supported library, now and in the future? I just do not want to use it just to find out two years later that the library is not supported anymore. I see this happening a lot in the open source world, where developers love to come up with new ideas, and creation of new libraries is highly favoured to grunt work that maintenance involves. I like it a lot because I like SQL :wink: and it gives me access to the raw power of SQL.

  2. In your experience, what would make more sense in a C#/F# hybrid web application that already uses EF: to piggyback on the existing EF db context even in F# or have F# use its own method via SQLProvider or SQLClient?

  3. I experimented a bit in linqpad with SQLProvider connected to large database - and experienced some delays when I ran simple F# code to query the database. I feel uneasy about this model where I have a TypeProvider that magically reverse engineers the database, process that I have little control over. There are all sorts of questions:

  • when does it happen: does it happen at compile time, does it happen in the editor (I use VS 2017)
  • what happens if I modify the database - how do I trigger a refresh in the editor or does it poll
  • what happens if there are SQL objects in the model that don’t exist in test or production? Usually during development you might end up experimenting with tables and you might forget about them.
    There seems to me that I have little control over what gets generated through the existing options. At least in the EF database first model, I add my entities and that’s that. I have control over this stuff.
  1. Any other ideas, suggestions? I read somewhere else about a dapper wrapper for F#.

Why do I want to move to F#? I am a Scala/Haskell and functional programming fan boy. The shop I work for is a Microsoft shop, so I have been reading about F# for quite a while and I started to like it a lot (I was surprised). I should have started on the F# path a long time ago. Ah, well, no regrets for now. The fsharpforfunandprofit site is awesome. A lot of the FP stuff transcends the programming languages. And F# has its own sweet spots.

Thanks!
Costa

Hi,

I am newbie about Microsft ecosystem, about SQLProvider is a good project, but i prefer use manual approach like Npgsql.FSharp

In my personal project i use this wrapper with Postgres and is a very nice experience.

About your first question, i think with fsharp projects have low contribuitors, or you help the projects or learn to live with some bugs