我首先发现使用 WCF 数据服务和实体框架代码时存在问题。
我有一个类 User 和 ServiceProvider。 User 类是 ServiceProvider 的祖先:
[DataServiceKey("Id")]
public class User
{
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
}
[DataServiceKey("Id")]
public class ServiceProvider : User
{
public string AdditionalInfo { get; set; }
public string ServiceDescription { get; set; }
}
当我尝试运行 wcf 数据服务时,出现错误:
服务器在处理请求时遇到错误。例外情况
消息是'属性'用户'和'服务提供商'是IQueryable的
类型“SocialNetwork.Domain.Entities.User”和
“SocialNetwork.Domain.Entities.ServiceProvider”并输入
'SocialNetwork.Domain.Entities.User' 是类型的祖先
'社交网络.域.实体.服务提供商'。请确保
每个类型层次结构只有一个 IQueryable 属性。”看
服务器日志以获取更多详细信息。异常堆栈跟踪是:...
我发现 Paul Mehner 的博客描述了这个问题,但我还没有找到解决方案。
博客链接:http://www.wintellect.com/CS/blogs/pmehner/archive/2010/02/10/windows-communication-foundation-data-services-astoria-the-stuff-they-should- have-told-you-before-you-started.aspx
您对如何解决此问题有任何想法吗?
谢谢你!
I found an issue working with WCF Data Services and Entity Framework code first.
I have a class User and ServiceProvider. Class User is an ancestor of the ServiceProvider:
[DataServiceKey("Id")]
public class User
{
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
}
[DataServiceKey("Id")]
public class ServiceProvider : User
{
public string AdditionalInfo { get; set; }
public string ServiceDescription { get; set; }
}
When I'm trying to run wcf data service I'm getting an error:
The server encountered an error processing the request. The exception
message is 'Property 'Users' and 'ServiceProviders' are IQueryable of
types 'SocialNetwork.Domain.Entities.User' and
'SocialNetwork.Domain.Entities.ServiceProvider' and type
'SocialNetwork.Domain.Entities.User' is an ancestor for type
'SocialNetwork.Domain.Entities.ServiceProvider'. Please make sure that
there is only one IQueryable property for each type hierarchy.'. See
server logs for more details. The exception stack trace is: ...
I found Paul Mehner's blog which describes this problem but I haven't found the solution.
A link to the blog: http://www.wintellect.com/CS/blogs/pmehner/archive/2010/02/10/windows-communication-foundation-data-services-astoria-the-stuff-they-should-have-told-you-before-you-started.aspx
Do you have any ideas how to fix this issue?
Thank you!
发布评论