I am writing my first WCF service. I have a few operations that are using Entity Framework - grabbing some data and returning JSON string.
I can invoke the operations successfully using the wcfClient, but when I try to invoke the operation in my own test console app I get the following error in the entity model constructor :
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. Code in DataContract class:
[DataContract]
public class DrawSystemService : IDrawSystemService
{
public string GetDrawEntry(string entryId)
{
using (MyEntities context = new MyEntities())
{
tblDrawEntry drawEntry = null;
try
{
drawEntry = context.tblDrawEntries.FirstOrDefault(e => e.DrawEntryID == new Guid(entryId));
}
catch (Exception ex)
{
}
string json = JsonConvert.SerializeObject(drawEntry, Formatting.Indented);
return json;
}
}
}
Code in console app:
WcfDrawSystemLibrary.DrawSystemService drawSystem = new DrawSystemService();
drawSystem.GetDrawEntry("665B534B-73EE-4385-A9BA-02A25CB5FE4D");