LINQPaq Querying UserQuery DB And Not Correct DB
This is a cross-post from a SO question. Since it doesn't seem to be drawing any attention, I figured I would ask here.
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:
But when I run
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
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
?
Comments
mydatabase
database on testing, but it will also query for a list of tables frommydatabase
when I initially expand the connection to show the tables. Immediately when I go to runEthnicities.Take (100)
is when LINQPad attempts to create an entirely new database. It is now throwing FK errors because I don't have the code set up the way it likes it. EfDBContext works perfectly fine (fetches all related data as expected) when ran normally.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.
You can verify it by running the following query: The location of your config should be a temporary file in %temp%\LINQPad. The content of the configuration file should contain an element, under connectionStrings with add name="UserQuery"...
I tried that, and still got the same issue. I wrote my App.config as so: And after removing my previous fix LINQPad still tried to create the UserQuery database. I also ran your provided code and got: Am I doing anything wrong here?
I solved it by adding a parameter-less constructor that calls the base constructor with the full name of my DbContext type as a parameter.
Joe, you wrote back in 2011 at the O'Reilly forums: I'm guessing that due to how the EF constructor is written, there is no solution other than the one that worked for Codeacula and myself?