F# Type Providers very very slow build

六月ゝ 毕业季﹏ 提交于 2020-01-01 03:18:05

问题


I'm playing around with Type Providers, specifically the sql entity framework type provider. I'm writing tests against a database that has a LOT of objects, and it's remote so the connection is a little slow. every time i build the project it takes a lot of time, good several minutes for the build to complete.

what am I missing why does the compiler doesn't cache the type information?

P.S. It's even worse with F# interactive....


回答1:


Try using the LocalSchemaFile attribute for the data provider. This points to a .csdl file that is used to generate the types. You can have the type provider update this file by setting the ForceUpdate attribute to true. To run from a cached schema simply set ForceUpdate to false. Here is how I do this 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>" >



回答2:


Besides what can be defined as a 'slow build', (if you are in the red green tdd development circle, builds quickly become slow!), I moved my client type provider code to a separate project. I already had ForceUpdate set to false, but still builds were slow (apparently still some background checking of the generated dbml files was going on, in my case wsdlschema files actually).

After moving all the type provider code to a separate projects, builds were significantly faster!

Note: loading the interactive was even more quick, only you have to add the reference to the dll for the types




回答3:


Seems like bottleneck is in remote connection. I also assume you have to edit and recmpile db access code frequently.

Some type providers can point to local SQL scripts instead of live connection, if it's not the case then make a local db which will replicate the schema (and static data in 'enum' tables if you have any). Connection for type providers/compiler and for runtime doesn't have to be the same.

There are tools to sync schemas once in a while e.g.Red Gate SQL Compare (this is one is great but not free), or simply regenerate full db schema SQL and recreate local database and run it once in a while (this also can be automated but it's a different story).



来源:https://stackoverflow.com/questions/17170748/f-type-providers-very-very-slow-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!