Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception message is On data context type there is a top IQueryable property whose element type is not an entity type

I'm bulding a WCFDataService hosted in IIS 7, I'm going to use Reflection Provider as data source provider. My project works if I keep the entity type definition in the same assembly where I defined the service, but dosen't work if I move the entity type to another referenced assembly;

I get the following error:

"server encountered an error processing the request. The exception message is 'On data context type 'EntityContainer', there is a top IQueryable property 'Cats' whose element type is not an entity type"

Service

public class WcfDataService1 : DataService<EntityContainer>
    {
        
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("Cats", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
          
        }
    }

Entity Container

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();
            }
        }

    }

Entity type

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

     public string Name { get; set; }
}

As I said above everithing work keeping the class Cat together with the other code, but I got the error moving the Cat class to a referenced assembly

What im missing?

like image 872
Ghini Antonio Avatar asked Nov 11 '14 12:11

Ghini Antonio


1 Answers

After 2 hours and strong head ache i found the problem by myself, I was referencing Microsoft.Data.Services.Client in my service and System.Data.Services.Client in the referenced project library where I was going to move the entity type. Hope my post can help someone else.

like image 98
Ghini Antonio Avatar answered Sep 20 '22 13:09

Ghini Antonio