Nov 16, 2010 at 4:00 PM

I have a property on an Entity called LastUpdateDate that I have set the StoreGeneratedPattern to "Computed".  I have also set the CSLA Setter to None.  The LastUpdateDate is actually generated at the database.  The problem is that your templates still want to write to this property even though there is no Csla setter and EF doesn't like you writing to a property that is set to Computed or Identity.  Would it be possible to remove any writing of a property with evither no Csla Setter or is set to Computed.  If not, I always have the work-around of setting both setter and getter to None and implement the properties myself, but I was wondering if there was an easier way.

Nov 16, 2010 at 4:19 PM

Hi brencld.

EF does not handle default database values very well. If you don't supply the value before inserting an entity to the database, you will get SqlDateTime overflow ( If you set column property to "Computed" in your EF model, next time you refresh the model that value will be lost. 

My solution: I have created a stored procedure that returns getdate() from the database server. I use that value in partial BeforeInsert method of my Business object.

Is this solution ok for you? If not, I'll add this request to the Issue Tracker.



Nov 16, 2010 at 4:32 PM

Howdy jbudimir,

Thanks for the reply, but it is incorrect.  It will return the database value, but you have to set it to computed in the designer and also manually set the property to Computed in the designer file due to a known bug in the design editor. 

You can find more info on that bug here

 I use triggers to generate the creation date and last update date, and as I have implemented the work around I described in my above post, it works perfectly.

Nov 16, 2010 at 6:07 PM

Maybe I did not express myself correctly. If you set property in the designer manually, this will work. But every time you refresh model from the database, this property will be reseted. So you'll have to remember that every time you refresh the model from the database, you need to set this property again.

I'll add this request to the Issue Tracker.



Nov 16, 2010 at 6:08 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Nov 16, 2010 at 6:26 PM

I have changed the template and now if property does not have setter, property value is not written to the EF entity during save operation. You can download the latest template from the source repository and simply copy->paste to your project. Don't forget to change emdx path after doing that. If you want I can build new VSIX file for you.




Nov 16, 2010 at 6:42 PM

Good point on the database updating.  This is a nasty nasty bug.

Dec 8, 2010 at 8:16 PM

Hurrah!  VS2010 SP1 beta looks like it fixes the entity designer.