EF 6 Code First ModelBuilder class missing IsRowVersion for timestamp types

Posts   
 
    
basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 10-Sep-2014 10:24:37   

Hi

This question concerns the Code First for EF6 in LLBLGenPro 4.2 and the handling of timestamp data types.

The ModelBuilder mapping class outputs this by default as the timestamp column is NOT NULL in the SQL Server 2012 database schema

config.Property(t => t.RowVersionStamp).IsRequired();

This results in a runtime error when trying to persist the entity to the database.

I changed the code to include the following (given below) and Entity Framework was able to identify the column as a timestamp column and I was able to save the data successfully to the database.


config.Property(t => t.RowVersionStamp).IsRequired();
config.Property(t => t.RowVersionStamp).IsRowVersion();

Is there a setting somewhere that controls this or is this something missing from the template that generates the model builder class.

I recall from EF V1 there was a project setting for EF concurrency but that does not appear to be in the later versions.

PS Looking at the template for this it does check for a specific setting, but I don't see this in the Project Settings : UseForOptimisticConcurrencyChecks

basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 10-Sep-2014 13:44:14   

I've looked at these settings in the online documentation:

Field settings (value type definition field, entity definition field) ForcedStoreGeneratedPatternValue. This setting specifies the forced value for StoreGeneratedPattern on the mapped target. By default, the setting is set to None, which means the value for StoreGeneratedPattern is left to the designer. Setting this to Identity or Computed will set StoreGeneratedPattern on the target's field if it's not an Identity already. Default value: None UseForOptimisticConcurrencyChecks. This setting controls whether the field is used in optimistic concurrency checks (true) or not (false, default). Default value: false

However these are not visible in the designer although they are in the framework settings file.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Sep-2014 18:35:51   
basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 10-Sep-2014 18:56:13   

Walaa wrote:

Would this answer your question? https://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=19639&HighLight=1

Yes it does! I have to say it is not obvious but once you know, you know. Thank you very much.