I have got a BaseEntity class which contains a, byte array called stamp, id and state, which every Entity inherits from I am mapping the stamp to
Property(t => t.Stamp).IsRequired().IsRowVersion();
this is set in BaseEntityConfiguration which is set like this
public BaseEntityConfiguration<T> : EntityTypeConfiguration<T> where T :B aseEntity
The mapping is done like this
var baseMapConfiguration = new BaseEntityConfiguration<EntityA>();
modelBuilder.Configurations.Add(baseMapConfiguration);
var entityAMap = new EntityAMap(baseMapConfiguration);
The database has Stamp ROWVERSION NOT NULL; on the Table EntityA I have code that handles DbUpdateConcurrencyException but this does not get caught even though the stamps are different Also there is no where clause on with the Stamp field which I would expected
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[LastModified] AS [LastModified],
[Extent1].[CreatedDate] AS [CreatedDate],
[Extent1].[Stamp] AS [Stamp]
FROM [dbo].[EntityA] AS [Extent1]
As you seen no where statement I have also tried it from the with a normal mapping set up but still get the same result
**I have found the problem EF is getting the latest Rowversion instead of the passed in one, How can I stop this. **
if (!EntityA.Stamp.Equals(orignal.Stamp))
{
ctx.Entry(orignal).OriginalValues["Stamp"] = xmlFile.Stamp;
}
I was missing these line of codes from the DAL, this is stop EF putting the current stamp as the search criteria.