I have a very basic code using Entity Framework to get a model in my MVC C# .NET Controller.
var myModel = myContext.MyData
.Where(m => m.ID == 1)
.FirstOrDefault();
string json = Newtonsoft.Json.JsonConvert.SerializeObject(myModel);
When I try to run this code, I get an error:
Error getting value from 'ServerVersion' on 'System.Data.SqlClient.
... If I press 'Continue', the view says:
[InvalidOperationException: Invalid operation. The coection is closed.]
Whats wrong?? What does SQL have to do with this? The same error comes if I do this in the View instead of the Controller.
