In this blog post we will talk about an error that occurs when we want to delete or update entities from Windows Azure Tables. Let’s assume that we have the following code:
Our code should look something like this:
TableServiceContext serviceContext;
…
serviceContext.AttachTo(“MyFooTable”,entity);
serviceContext.DeleteObject(entity);
serviceContext.SaveChanges();
When we run the code we will see the following error message:One of the request inputs is not valid.
The source of the problem is the ETag. ETag is used to track changes of an entity and commands like delete use this ETag to check if the entity that is deleted is the last version of entity. If we are share that we want to delete this entity we can set the 3th parameter of AttachTo to “*”. Using “*”, you will specify to the context to not track the entity based on the ETag. Our code should look something like this:
TableServiceContext serviceContext;
…
serviceContext.AttachTo(“MyFooTable”,entity, “*”);
serviceContext.DeleteObject(entity);
serviceContext.SaveChanges();
Thanks! I hit the same and your post saved my time.
ReplyDelete