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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With