Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

One of my projects using Entity Framework 5 is acting very strange.

If I run the application on the same machine as the SQL Server 2012 instance, everything works perfectly. But if I run the application on a remote machine, queries won't get executed. There is no exception. I can leave the application running for hours without any response or activity.

I've checked that the app is using the connection string. It absolutely does.

Config:

<connectionStrings>
   <add name="ConnectionName" 
        connectionString="metadata=res://*/MyContext.csdl|res://*/MyContext.ssdl|res://*/MyContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.0.11;initial catalog=MyDatabase;user id=MyUser;password=MyPassword;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
        providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
    <parameters>
      <parameter value="v11.0" />
    </parameters>
  </defaultConnectionFactory>
</entityFramework>

The constructor for my context:

public partial class MyEntities : DbContext
{
  public MyEntities (string connectionStringName) : base("name=" + connectionStringName)
  {
  }
}

Even a simple code block like this replicates the behaviour:

MyEntities dbContext = new MyEntities("ConnectionName");
List<Product> products = dbContext.Products.ToList();

So to recap. This code executes just fine on the local machine where the SQL instance is running. On a remote machine this code does nothing. The application just sits there without throwing an exception. Not a timeout, not a connection exception. Nothing at all.

The SQL Server instance is available remotely. I've checked that as well. Other applications using the same database/instance run perfectly remotely (not using Entity Framework but OpenAccess instead)

And also the SQL management studio has no trouble executing queries remotely.

share|improve this question
Are yo sure there's not some infinite timeout involved? – Gert Arnold yesterday
I'm pretty sure there's no reason for it to time out. I've just written a simple test app in a different solution. It uses the same database and the same connectionstring/configsection and that test app does work on remote machines. – Erik 16 hours ago

1 Answer

Turns out it had nothing to do with the Entity Framework.

The published applications on my remote machines were missing a DLL from my old ORM (open access). Even though there was absolutely no reference left to the old ORM's DLLs it still needed them somehow.

I was using a background worker to execute the queries and somehow that's why it did not throw the missing DLL exception on the remote machines.

I have to add that on the local machine, the old ORM was installed. That's why it did work locally. The remote machines never had open access installed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.