使用EF 4在数据服务中公开Pocos时出错 [英] Error in exposing Pocos in Data services using EF 4
问题描述
我尝试将Pocos与EF一起使用(根据本文 - http://blogs.msdn.com/b/adonet/archive/2009/05 /21/poco-in-the-entity-framework-part-1-the-experience.aspx )
并尝试使用WCF数据服务公开它。请注意,edmx文件和上下文在1个程序集中,Pocos在单独的Web项目中处于单独的程序集和服务中。我收到了下面的错误,并寻找解决方案
I tried using Pocos with EF (as per this article - http://blogs.msdn.com/b/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx) and tried to expose it using WCF Data services. Note, the edmx file and context are in 1 assembly, the Pocos are in separate assembly and service in a separate web project. I got the error below and looked for a solution
我找到了这个帖子 - http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/601491ab-9c46-4fdf-88a7-c7392e5dbcdf 。
I found this thread - http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/601491ab-9c46-4fdf-88a7-c7392e5dbcdf.
并尝试实施解决方案并添加到service.cs类,但仍然出现相同的错误。
and tried implementing the solution and added to the service.cs class, but still the same error.
protected override MycontainerContext CreateDataSource()<br/> {
MycontainerContext context = new MycontainerContext ();<br/>
context.MetadataWorkspace.LoadFromAssembly(typeof(MycontainerContext).Assembly);<br/>
return context;
}
推荐答案
ok所以我调试了它,我可以清楚地看到modelcontainer正确加载所有objects.objectset。但该服务仍然会引发此错误。
ok So I debugged it and I can clearly see modelcontainer correctly loads all objects.objectset. But the service still throws this error.
有人请提供建议。
这篇关于使用EF 4在数据服务中公开Pocos时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!