TableServiceContext.SaveChanges() fails
I am looking for pointers to why the above method would fail.
In my TableServiceContext subclass I have:
public void AddDevice(Device d)
{
d.PartitionKey = "A";
d.RowKey = Guid.NewGuid().ToString();
this.Add开发者_运维知识库Object("Devices", d);
this.SaveChanges();
}
The call to SaveChanges()
fails with a very generic message to diagnostics:
An error occurred while processing this request.. Stack: at System.Data.Services.Client.DataServiceContext.SaveResult.HandleBatchResponse()
at System.Data.Services.Client.DataServiceContext.SaveResult.EndRequest()
at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
at WorkerRole1.DeviceServiceContext.AddDevice(Device d) in DeviceServiceContext.cs:line 30
Any ideas what could be amiss? The Devices table exists. The storage account exists and seems ok.
Many thanks!
One possibility is that the Device class is not serializable.
The exception could be caused by several things, see this blog post for some examples.
After a lot of tracing and head scratching, it turns out that the SaveChanges() method was unhappy about one of the properties in my entity object. The inner exception spoke about "method not implemented". Fixed but a more precise exception message would have been nice...
I'm new in Azure, but I've been told that Azure does NOT admit UpperCase in Blob, Queues or Table names... Maybe the problem is not the object or the method, but the Tablename since it's called "Devices" instead "devices"... But I'm not sure... Hope this will help.
精彩评论