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="data source=192.168.0.11;initial catalog=MyDatabase;user id=MyUser;password=MyPassword;MultipleActiveResultSets=True;App=EntityFramework""
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.