Home
Options

Strange Issue: Everything looks fine, but no data returned (0 results)

I have installed first the release version, and afterwards the beta (4.43.06) of LINQPad, but I have experienced a very strange issue.

I am trying to access the data from my MVC 4 project using EF 5 and SQL Express 2012. I have added the connection by referencing my assembly and web.config. If I click "Test" it completes successfully. It also shows all the classes of my DbContext (except, some inherited classes, that don't show up? I'm using Table Per Concrete Type (TPC)?).

The strange thing is that when I try a query, even some of the simple standard ones (right-click options, Take 100 etc.), it shows it querying and then shortly after returns 0 results. (Yes, I am quite sure the database contains data - my application works fine with it, as does SSMS). If it wasn't for that rather important detail I'd swear it was working like it should. No errors anywhere, just no data either.

Any ideas?

Best regards,

Martin

Comments

  • Options
    You can see where the data's coming from by running this query:

    this.Connection.ConnectionString
  • Options
    Hi Joe,

    That returns "'UserQuery' does not contain a definition for 'Connection' and no extension...", I have also tried with the name of one of my classes that is listed in the left hand side instead of "this", and with the name of my DbContext, and receive a similar response.

    Best regards,

    Martin

    P.S: Currently reading C# 5.0 In A Nutshell - Great book, thanks!
  • Options
    edited January 2013
    Ah - I found it! The connection drop-down lists several connections now. I'm not sure when they all got added during my attempts to get it to work, but the default choice of "(MyDbContextName) in (MyAssemblyName).dll" seemed quite credible. However, there was another choice starting with my SQL Express instance (".\SQLEXPRESS.(FullyQualifiedDbContextName)", and selecting that suddenly made data available. In my attempts to get it to work I tried adding the connection manually, and that may or may not have been what added that connection to the list.

    The weird thing was that the test was successful, and when running a query it said "Querying" and then "Query successful", but with 0 results. Anyway, to anyone else facing this issue - check your connection drop down, and if necessary try to add a connection to the SQL EXPRESS instance manually.
  • Options
    OK - I see what's happening now. I'm querying the database directly, not my EF entities. It gives me more or less the same results though, except that I can't use navigation properties on inherited classes like I can in my app. I can create the joins manually and then it works.

    If there was a way to get the full EF experience (including support for my inherited entity classes) I would love to hear about it, though?
Sign In or Register to comment.