How to speed up build time for F# project with SQL TypeProvider

It is good to read documentation. There is so many useful information that might save a lot of time…
I’m working on some project, where I use F# TypeProviders to connect with some legacy database. And each time I built my project, I was reloading database scheme. So each build took too long. At first, I’ve moved my F# code to new solution, so I didn’t have to wait for it each time I was testing my app. But sometimes I still have to fix and rebuild part of the code with data access. I it still took a lot of time. And today comes realization: „Maybe there is some way to cache database scheme?”.
Of course it is, it is F#!
When declaring SqlDataConnection type provider, there two additional parameters that could be use:

  • LocalSchemaFile
  • ForceUpdate

First one is just path to file, second one could be used to force VS to regenerate cached file if there were some change in application. Nice thing is that such file could be shared amongst other F# projects, you just need to put correct path. As I have two projects in solution: first with data access for my application and second with some tests, my context definition for both projects looks like that:

type internal EntityConnection = SqlDataConnection<ConnectionStringName="appTypeProvider",ConfigFile="App.exe.config", LocalSchemaFile="../appSchema.dbml", ForceUpdate=false>

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *