Adam
Adam

Reputation: 16199

Update on TableController in Azure Mobile Services fails

When I do a Patch (updateasync) on a tablecontroller I get the following error:

iisexpress.exe Error: 0 : Message='The client is attempting to use optimistic concurrency in
connection with updates and inserts but the current 'SimpleMappedEntityDomainManager`2' 
implementation does not set the original version required to support this. Please implement the 
method 'SetOriginalVersion' and provide the original value.', 
Id=00000000-0000-0000-5d00-0080000000ff, Category='App.Controllers.Tables'

I am using the MappedEntityDomainManager as I have a pre-existing DB that I have hooked up.

Lookup and Insert all work fine.

Upvotes: 1

Views: 366

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87218

Try updating your SimpleMappedEntityDomainManager<TDTO, TModel> implementation with the following method:

protected override void SetOriginalVersion(TModel model, byte[] version)
{
    this.context.Entry(model).OriginalValues["Version"] = version;
}

Where "Version" is the name of the property in your model class which stores the version of the item (usually of type timestamp)

If you do not have any property in your database that stores the version (mapped to the Version or __version property in the outgoing DTO), then you can have an empty override:

protected override void SetOriginalVersion(TModel model, byte[] version)
{
}

I couldn't find any documentation for this feature, so I'll forward this issue to the product team to have it corrected.

Upvotes: 1

Related Questions