I have a Silverlight 4 application with EntityFramework as data layer.
There are two entities: Customer and Products. When I get customer from a database, the related products are also read, as I added related 'Include' attribute in customer's metadata and call Include method in get query:
public IQueryable<customer> GetCustomerSetById(int customerId)
{
return this.ObjectContext.CustomerSet
.Include(o => o.Products)
.Where(o => o.Id = customerId);
}
The problem that when I change any property in customer's product I get this exception:
This EntitySet of Type 'MyApp.Web.Models.Product' does not support the 'Edit' operation.
But everything works if I read customer products directly, e.g. not through customer entity (CustomerContext) , but via product one (ProductContext).
Also there is the IsReadOnly=true property in a product entity.
UPDATE:
I have all CUD operations and also marked all of them with related Insert, Update and Delete attributes. Otherwise it wouldn't work at all, but it works for me in some cases as I wrote above.
Any ideas?