LinqPad Test Looks For Correct DB But Queries Wrong One

会有一股神秘感。 提交于 2019-12-11 18:15:46

问题


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.

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'

But when I run Ethnicities.Take (100) I see:

SELECT Count(*) FROM sys.databases WHERE [name]=N'UserQuery'

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?


回答1:


I found this:

http://forums.oreilly.com/topic/49460-linqpad-entity-framework-41-poco-query-problem/

And adding this line of code in my DbContext file fixed it:

public EfDbContext() : base("mydatabase") { }

Unsure if this is still a known bug or an issue with me, since I tried the beta and still had the same issue.



来源:https://stackoverflow.com/questions/17243088/linqpad-test-looks-for-correct-db-but-queries-wrong-one

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