F # Type Suppliers Very Slow Builds

I play with type providers, in particular with an entity type provider of the sql class. I am writing tests against a database with a large number of objects, and it is deleted, so the connection is a bit slow. Each time I build a project, it takes a lot of time, just a few minutes to complete the assembly.

what am I missing, why does the compiler not cache type information?

PS This is even worse with F # interactive ....

+6
source share
3 answers

Try using the LocalSchemaFile attribute for the data provider. This points to the .csdl file that is used to generate types. You can specify that a provider of this type update this file by setting the ForceUpdate attribute to true. To run from a cached scheme, simply set ForceUpdate to false. This is how I do it with the SqlDataConnection provider, which is very similar to the SqlEntityConnection provider.

type schema = SqlDataConnection< LocalSchemaFile = "Schema.dbml", ForceUpdate = false, ConnectionString = @"Data Source=<insert your connection string here>" > 
+11
source

Besides what can be defined as “slow build” (if you are in the red-green circle of tdd development, it quickly becomes slow!), I moved the code of the client code provider to a separate project. I already set ForceUpdate to false, but still the assemblies were slow (apparently, some background checking of the generated dbml files continued, in my case the wsdlschema files actually were).

After transferring all the code of the type provider to individual projects, the assembly was much faster!

Note. Downloading interactivity was even faster, only you need to add a link to the dll for types

0
source

Looks like a bottleneck in the remote connection. I also suggest that you need to edit and re-enter the database access code frequently.

Some type providers may point to local SQL scripts instead of a live join, if this is not the case, then create a local database that will replicate the schema (and static data in the enum tables, if you have one). The connections for type / compiler providers and for the runtime need not be the same.

There are tools for synchronizing schemas from time to time, for example egRed Gate SQL Compare (this is great, but not free), or just regenerating a full SQL DB schema, re-creating a local database and starting it from time to time (this can also be automated). but this is a different story).

0
source

Source: https://habr.com/ru/post/947556/


All Articles