I have a DateTime column in my app that gets auto calculated by SQLServer. It works great when creating the row. However, I would like to be able to updated later. I have the property marked with [DatabaseGenerated(DatabaseGeneratedOption.Computed)].
Is it possible to updated a property like that in EF?
No, with DatabaseGeneratedOption.Computed EF will never include the property in update and insert statements. In stead, it will always read its value after such statements.
If you have to update the property in client code you have no other option than removing the data annotation an make it an ordinary updateable property. You can set a default value in the owning class's constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With