Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework 使用LinqPad查询Ef上下文:参数异常_Entity Framework_Entity Framework 4_Linqpad - Fatal编程技术网

Entity framework 使用LinqPad查询Ef上下文:参数异常

Entity framework 使用LinqPad查询Ef上下文:参数异常,entity-framework,entity-framework-4,linqpad,Entity Framework,Entity Framework 4,Linqpad,我在linqpad中添加了Ef连接,如下所示 正如您所看到的,连接已成功添加,但当我想查询此连接时,会出现以下异常 The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. 它似乎与连接字符串连接,但如何解决它,我不知道。上下文在asp.net mvc项目中定义(没有单

我在linqpad中添加了Ef连接,如下所示
正如您所看到的,连接已成功添加,但当我想查询此连接时,会出现以下异常

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

它似乎与连接字符串连接,但如何解决它,我不知道。上下文在asp.net mvc项目中定义(没有单独的数据访问项目),连接字符串像往常一样在web.Config文件中

1) 通过执行以下命令,查找LINQPad用于其配置文件的路径:AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.Dump()

这为我返回了以下内容:C:\Program Files\LINQPad4\LINQPad.config

  • 我很惊讶这个返回的是LINQPad.config而不是LINQPad.exe.config 这是您通常期望的,因为大多数.NET应用程序将>文件命名为与可执行文件相同的名称

  • 获取App.config并将其复制到命名配置上面的位置 把你归还的东西归档。在我的例子中是LINQPad.config

  • 关闭LINQPad或已打开以执行程序集的选项卡,然后重新打开以使LINQPad读取配置文件


  • 最新版本的LINQPad支持直接连接到具有DbContext或ObjectContext的项目。使用该连接类型,您可以在设置连接时指定app.config/web.config