I ran into this a minute ago and the issue was the virtual keyword on a collection within my class, like so:
public class Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public virtual ICollection<Thing> Things { get; set; }
}
Get the rid of the virtual and everything is good. Without seeing how the model is built up, can't so for sure if this is your problem, but take look. Side note, you don't need to call AsQueryable() in your Get() method. Returning dbContext.Categories will
work just fine.
Jesse Willia...
Member
2 Points
1 Post
Re: You must write an attribute 'type'='object' after writing the attribute with local name '__ty...
Feb 24, 2012 02:16 AM|LINK
I ran into this a minute ago and the issue was the virtual keyword on a collection within my class, like so:
public class Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public virtual ICollection<Thing> Things { get; set; }
}
Get the rid of the virtual and everything is good. Without seeing how the model is built up, can't so for sure if this is your problem, but take look. Side note, you don't need to call AsQueryable() in your Get() method. Returning dbContext.Categories will work just fine.