简体   繁体   中英

F# SqlDataConnection Type Provider - Run once, instead of on every compile

Is there a good example or explanation of how to crawl you Development version of your database once with the SqlDataConnection type provider declaration, but not run it on every compile? And what is the correct way to specify the connection as a string parameter instead of string literal?

How to avoid hitting the DB on every compile

Use the LocalSchemaFile static parameter with ForceUpdate = false . See this answer for more info.

How to avoid using a string literal for the connection string

Two options:

  • Put your connection string in app.config and use ConnectionStringName to point to it.

  • Use local schema file for compile-time, then pass an arbitrary connection string at runtime.

     type NorthwndDb = SqlDataConnection<ForceUpdate=false, LocalSchemaFile="schema.dbml"> let db = NorthwndDb.GetDataContext(realConnectionStringHere)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM