Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity framework model first timestamp

I am developing Entity Framework based app. I am using model-first approach. I would like to handle the concurrency issues. As written in many articles I am going to do it by turning the ConcurrencyMode to fixed on a field which is a timestamp. At the moment I am facing the problem - I cannot add field (column) of type timestamp. How can I do it in model?

As written here:

http://social.msdn.microsoft.com/Forums/is/adodotnetentityframework/thread/1ed8d1e4-9d78-4593-9b10-33e033837af8\

I tried installiing Entity Designer Database Generation Power Pack, but still I see no possibility to have the timestamp generated from the model (I have even tried setting it manually in edmx file, but still I am not receiving timestamp fcolumn in generated database).

Please help.

like image 288
rideronthestorm Avatar asked Mar 06 '12 09:03

rideronthestorm


People also ask

What is TimeStamp in Entity Framework?

The TimeStamp attribute is used to specify that a property should take part in concurrency management. The TimeStamp attribute is only valid if applied to a property that is a byte array. How this is implemented is dependent on the current database provider. In SQL Server, this will map to a rowversion type.

How do I code first in Entity Framework?

Step 1 − First, create the console application from File → New → Project… Step 2 − Select Windows from the left pane and Console Application from the template pane. Step 3 − Enter EFCodeFirstDemo as the name and select OK. Step 4 − Right-click on your project in the solution explorer and select Manage NuGet Packages…

What is DB first?

Database First allows you to reverse engineer a model from an existing database. The model is stored in an EDMX file (. edmx extension) and can be viewed and edited in the Entity Framework Designer. The classes that you interact with in your application are automatically generated from the EDMX file.

How do I use code first in Entity Framework Core?

Code-First is mainly useful in Domain Driven Design. In the Code-First approach, you focus on the domain of your application and start creating classes for your domain entity rather than design your database first and then create the classes which match your database design.


1 Answers

I think the database type timestamp maps to a Binary property type in EF.

My model's timestamp column is type Binary with length 8, fixed length true, StoreGenratedPattern is Computed.

EDIT: Actually not possible without changing the t4 template as explained here: Entity Framework timestamp Generate Database issue

like image 163
user917170 Avatar answered Oct 24 '22 12:10

user917170