I’ve been working on this issue for a while now and just can’t get around it. Any help would be much appreciated…
Using Azure Table Storage (not development storage) I’m simply trying to delete a row from a table:
Public Sub DeleteByItemId(pairItemId As String)
Dim item = (From c In _ServiceContext.UserTable Where c.Id = pairItemId Select c).Single()
_ServiceContext.DeleteObject(item)
_ServiceContext.SaveChanges()
End Sub
This causes an error: “The context is not currently tracking the entity.”
And this approach:
Public Sub DeleteByItemId(itemId As String)
Dim item = New <object type>
item.PartitionKey = "sandbox"
item.RowKey = itemId
_ServiceContext.AttachTo(<table name>, item, "*")
_ServiceContext.DeleteObject(item)
_ServiceContext.SaveChanges()
End Sub
Errors with this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>InvalidInput</code>
<message xml:lang="en-US">One of the request inputs is not valid.
RequestId:e37b0824-3336-4089-b6ac-2824438618f6
Time:2012-08-07T01:37:28.2741813Z</message>
</error>
How the service context gets created:
Public Sub New()
Dim storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString")
_ServiceContext = New OroosoUserPairedAccountDataServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials)
_ServiceContext.IgnoreResourceNotFoundException = True
_ServiceContext.MergeOption = MergeOption.NoTracking
' Create the tables
' In this case, just a single table.
storageAccount.CreateCloudTableClient().CreateTableIfNotExist(<table name>)
End Sub
Fiddler hasn’t revealed anything interesting.
I’m out of ideas…
Again, any help would be much appreciated.
Cheers
Remove
_ServiceContext.MergeOption = MergeOption.NoTracking. This is keeping theDataServiceContextfrom tracking the entity.