Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IsRowVersion can only be configured for Byte array properties

I recently upgraded from EntityFramework 5 to 6 via the NuGet updater. Everything seemed to go well and I built and executed my application. When I tried to retrieve the first entity from the database, I received this error:

The property 'UpdatedDate' is not a Byte array. IsRowVersion can only be configured for Byte array properties.

Here is the piece of code it is referring to:

[Timestamp]
public virtual DateTime UpdatedDate { get; set; }

I tried removing the timestamp attribute, but got the same error regardless. How do I fix this so I can run my application with EF6?

like image 511
Sparafusile Avatar asked Dec 04 '13 18:12

Sparafusile


People also ask

Which method is used to apply configuration to entities or their properties in the Entity Framework Core?

Property Mapping. The Property method is used to configure attributes for each property belonging to an entity or complex type.

Which among the following is a fluent API method that can be used to configure a default value for the column that the property maps to?

The Entity Framework Core Fluent API HasDefaultValue method is used to specify the default value for a database column mapped to a property.

How do you configure a primary key for an entity in Entity Framework fluent API?

Configuring a primary key By convention, a property named Id or <type name>Id will be configured as the primary key of an entity. Owned entity types use different rules to define keys. You can configure a single property to be the primary key of an entity as follows: Data Annotations.

What is fluent API used for?

Entity Framework Fluent API is used to configure domain classes to override conventions. EF Fluent API is based on a Fluent API design pattern (a.k.a Fluent Interface) where the result is formulated by method chaining. In Entity Framework Core, the ModelBuilder class acts as a Fluent API.


1 Answers

Attributes in EF

If you use [TimeStamp] attribute, then the property should be byte[]
This is then mapped to Rowversion in SQL server

If you want some other field type as a concurrency field. The use the attribute [ConcurrencyCheck]

like image 114
phil soady Avatar answered Oct 02 '22 04:10

phil soady