.net - Adding TimeStamps with EF 4.3 Migrations -
i'm using code first migrations , i'm altering model add timestamp fields tables. i'm trying add timetamp fields in second migration. here sample of code looks like
public class user { public int userid { get; set; } public string username { get; set; } public byte[] timestamp { get; set; } } public class usermodelconfiguration: entitytypeconfiguration<user> { public usermodelconfiguration() { property(p => p.username).isrequired().hasmaxlength(250); property(p => p.timestamp).isrowversion(); } }
the generated migration looks
public override void up() { addcolumn("users", "timestamp", c => c.binary(nullable: false, fixedlength: true, timestamp: true, storetype: "rowversion")); }
when execute update-database command, error message says "defaults cannot created on columns of data type timestamp. table 'users', column 'timestamp'. not create constraint" moved data table, didn't solve issue.
how can go adding timestamp field migration set?
use nullable:true
. timestamp column have null
in column specification filled anyway.
Comments
Post a Comment