efcore icon indicating copy to clipboard operation
efcore copied to clipboard

The order of calls for ValueGeneratedOnAddOrUpdate, HasDefaultValueSql

Open chandrush opened this issue 10 years ago • 1 comments

Depending on the order of calls a get different results for generated migrations.

Example. RecordVersion is the property with DateTime type. This setup ie.Property(e => e.RecordVersion) .HasDefaultValueSql("GetDate()") .ValueGeneratedOnAddOrUpdate(); results in this column definition: [RecordVersion] AS GetDate()

This setup ie.Property(e => e.RecordVersion) .ValueGeneratedOnAddOrUpdate() .HasDefaultValueSql("GetDate()"); results in this column definition [RecordVersion] datetime2 NOT NULL DEFAULT (GetDate())

Does it the right behaviour? I prefer the second one. Update on the column I'm going to make with the trigger. Also, the second case allows me to put an index on the column, and the first one doesn't.

Used libraries are: "EntityFramework.Core": "7.0.0-rc1-final", "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final", "EntityFramework.Commands": "7.0.0-rc1-final".

chandrush avatar Mar 19 '16 17:03 chandrush

dupe of #4328 Already fixed in latest and will be shipped in RC2 release

smitpatel avatar Mar 20 '16 07:03 smitpatel