我正在寫我的第一個WCF服務。我有幾個使用Entity Framework的操作 - 獲取一些數據並返回JSON字符串。WCF與EntityFramework
我可以調用成功使用wcfClient的操作,但是當我嘗試調用我自己的測試控制檯應用程序的運行我得到的實體模型構造以下錯誤:
指定命名的連接或者不在配置中找到,不打算與EntityClient提供程序一起使用,或無效。代碼DataContract類:
[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;
}
}
}
代碼在控制檯應用程序:
WcfDrawSystemLibrary.DrawSystemService drawSystem = new DrawSystemService();
drawSystem.GetDrawEntry("665B534B-73EE-4385-A9BA-02A25CB5FE4D");
謹慎縮小這個範圍 - 即更具體的 – tom 2012-03-27 14:37:23