我在这里看到了一些关于堆栈溢出的相关问题,但是没有一个看起来有答案。我会提出这个问题,然后包括我找到的相关SO问题的链接。从F#脚本使用app.config
我有一个用C#编写的利用实体框架的核心域库。因此,EF需要dbcontext将连接字符串传递给基础(dbcontext)。在我的情况下,连接字符串居住在app.config(或web.config)当然取决于顶级项目,名称是“AnnotatorModel”。
我需要从我的F#脚本中实例化DBContext来测试一些查询和分析。
我已经将这个添加到了我的F#项目中的app.config中,并尝试了一些关于SO的答案但没有成功。有没有人知道一个简单易行的方法来实现这一目标?
这是代码,意识到它试图实例化dbcontext,AnnotatorModel时破坏。
let PredictBestEntities (number:int) (tokens:string seq) =
let db = new AnnotatorModel()
tokens
|> Seq.map ...etc etc
谢谢, 〜大卫
相关问题:
Get and use connection string from App.config F# AppSettings provider
App.config and F# Interactive not working
将此与使用ConfigurationManager(在程序集System.Configuration中)读取值结合起来,该程序使您可以在指定的路径下加载.config文件.. – thinkbeforecoding