New Posts New Posts RSS Feed: Code First and RowVersion
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Code First and RowVersion

 Post Reply Post Reply
Author
pcournoyer View Drop Down
Newbie
Newbie


Joined: 19-Dec-2011
Location: Canada
Posts: 2
Post Options Post Options   Quote pcournoyer Quote  Post ReplyReply Direct Link To This Post Topic: Code First and RowVersion
    Posted: 21-Dec-2011 at 7:17pm
Hi DenisK,

Yes indeed, after I did my post yesterday I was thinking that this is purely an EF Code First problem since it occurs with EF configuration only.

Sorry for the noise and thanks for the tip.

Patrick
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 21-Dec-2011 at 11:17am
Hi pcournoyer,

It seems that you have multiple questions here so I'm going to try and address them one by one.

If I put the RowVersion property in the EntityBase class, I get the following error at run-time:
"The store generated pattern 'Computed' is not supported for properties that are not of type 'timestamp'  or 'rowversion'."

This sounds like a pure EF Code First question. Have you tried this scenario without DevForce involved? 

I googled the error and found 2 good links that might help you.


Also, the Id column is only set as Identity for the EntityBase table. The Id column in the tables for the derived classes is NOT set as Identity

Hmm, I don't quite follow this. If your EntityBase.Id column is set to Identity, how are you setting your DerivedEntity.Id to anything other than Identity? Furthermore, what are you setting it to?
Back to Top
pcournoyer View Drop Down
Newbie
Newbie


Joined: 19-Dec-2011
Location: Canada
Posts: 2
Post Options Post Options   Quote pcournoyer Quote  Post ReplyReply Direct Link To This Post Posted: 19-Dec-2011 at 5:34pm
I am currently evaluating DevForce and I seem to have reached a dead end trying to put a RowVersion attribute in a base entity using Code First. Here is my setup:
  • DevForce 6.1.4 release.
  • abstract EntityBase containing various "commons" stuff such as Id, CreationDate, ModificationDate, RowVersion...
  • Several entity types derive from it.
  • Use fluent mapping to setup TPC - Table Per Concrete Type (calling map.MapInheritedProperties() in the EF EntityTypeConfiguration<> classes for derived entities).
  • Silverlight 5 client application .
  • Separate model project (class library)

If I put the RowVersion property in the EntityBase class, I get the following error at run-time:
"The store generated pattern 'Computed' is not supported for properties that are not of type 'timestamp'  or 'rowversion'."
It makes no difference whether I tag the property as a RowVersion either using the [Timestamp] data annotation or using the EF fluent interface.

If I put the RowVersion in the derived entities, I get a compile time error stating that I cannot add concurrency checks in derived classes.

Also, the Id column is only set as Identity for the EntityBase table. The Id column in the tables for the derived classes is NOT set as Identity. As a result, the temporary negative Id assigned by the client (e.g. -100) gets stored in the database such that on the second insert I get a key violation exception.

So I am at a loss here...it seems to me that using a base entity is not that useful unless I am missing a key ingredient...
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down