3

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

stefando
  • 495
  • 1
  • 7
  • 13

1 Answers1

4

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; }
Kelly Adams
  • 750
  • 4
  • 15