Question

WCF Data Services with Entity Framework is automatically handling ETag headers (defined using [ETagAttribute] or automagically from [TimestampAttribute]).

I created WebApi2 OData controller from scaffolding. My entity have a valid timestamp (rowversion) property. However I don't see the ETag header in http response.

How can I enable valid ETag handling with OData + Web Api 2 + EF 6?

Thanks, Stefan

Was it helpful?

Solution

WebAPI v2.2 supports OData v4 and has support for ETags. See the "Support for ETags" section in this MSDN blog post. You can use either the [TimeStamp] attribute or the [ConcurrencyCheck] attribute but not both. An example property on your model would look like:

[Timestamp] 
public byte[] RowVersion { get; set; }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top