LinqPad测试寻找正确的数据库,但查询错误 [英] LinqPad Test Looks For Correct DB But Queries Wrong One
问题描述
我已经在LINQPad中创建了一个使用项目的EfDBContext的连接.在最近的一些问题之后,我现在可以获取它来查询表,但在执行时会创建一个全新的模式.
I have created a connection in LINQPad that uses a project's EfDBContext. After some recent issues I can now get it to query a table, but when it does it created a whole new schema.
因此,当创建连接(实体框架POCO连接)时,当我单击测试"时,探查器向我显示:
So, when creating the connection (Entity Framework POCO Connection), when I click "Test" the Profiler shows me:
SELECT Count(*) FROM sys.databases WHERE [name]=N'mydatabase'
但是当我运行Ethnicities.Take (100)
时,我看到了:
But when I run Ethnicities.Take (100)
I see:
SELECT Count(*) FROM sys.databases WHERE [name]=N'UserQuery'
之后是所有命令以生成架构.我在做什么错或需要更改以读取mydatabase
中的数据?
Followed by all the commands to generate the schema. What am I doing wrong or need to change to get it to read the data in mydatabase
?
推荐答案
我发现了这一点:
http://forums.oreilly .com/topic/49460-linqpad-entity-framework-41-poco-query-problem/
并在我的DbContext文件中添加以下代码行即可对其进行修复:
And adding this line of code in my DbContext file fixed it:
public EfDbContext() : base("mydatabase") { }
不确定这是否仍然是已知的错误或与我有关的问题,因为我尝试了Beta并仍然遇到相同的问题.
Unsure if this is still a known bug or an issue with me, since I tried the beta and still had the same issue.
这篇关于LinqPad测试寻找正确的数据库,但查询错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!