异常消息是On数据上下文类型,有一个顶级IQueryable属性,其元素类型不是实体类型

Ghi*_*nio 4 .net c# wcf wcf-data-services odata

我建立了我在IIS 7中托管的WCFDataService,我将使用Reflection Provider作为数据源提供者.我的示例工作,如果我将实体类型定义保持在我定义服务的同一个程序集中,但是如果我将实体类型移动到另一个引用的程序集并且出现以下错误则不起作用

"服务器遇到处理请求的错误.异常消息是'在数据上下文类型'EntityContainer',有一个顶级IQueryable属性'Cats',其元素类型不是实体类型"

服务

public class WcfDataService1 : DataService<EntityContainer>
    {

        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("Cats", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;

        }
    }
Run Code Online (Sandbox Code Playgroud)

实体容器

public class EntityContainer
    {
        public IQueryable<Cat> Cats
        {
            get
            {
                var s = new List<Cat>();
                var c1 = new Cat {Id = 1, Name = "Fufi"};
                var c2 = new Cat {Id = 1, Name = "Felix"};
                s.Add(c1);
                s.Add(c2);
                return s.AsQueryable();
            }
        }

    }
Run Code Online (Sandbox Code Playgroud)

实体类型

[DataServiceKey("Id")]
public  class Cat 
{
     public int Id { get; set; }

     public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

现在,正如我上面说的那样,如果我将类Cat与其他代码保持在一起,那么我会说错,但如果我将Cat移动到引用的程序集中,我会收到错误

什么我失踪了?

Ghi*_*nio 5

经过2个小时和强烈的头疼我自己发现了问题,我在我的服务中引用了Microsoft.Data.Services.Client,在引用的项目库中引用了System.Data.Services.Client,我将移动实体类型.希望我的帖子可以帮助别人.谢谢