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.


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


EF 6.1, I have this:

public partial class DepartmentEFEntity
{

    Guid DepartmentUUID { get; set; }

    public byte[] TheVersionProperty { get; set; }
}

and then:

        modelBuilder.Entity<DepartmentEFEntity>().Property(o => o.TheVersionProperty).HasColumnType("timestamp").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed).IsRowVersion();

When I script out the table, I get this:

CREATE TABLE [dbo].[Department](
    [DepartmentUUID] [uniqueidentifier] NOT NULL,
    [TheVersionProperty] [timestamp] NOT NULL
    )
链接地址: http://www.djcxy.com/p/90232.html

上一篇: 如何使用模型生成自动迁移脚本

下一篇: 实体框架模型的第一个时间戳