I'm attempting to include some derived data (calculated on the database) in an entity using Entity Framework Code First.
To do this, I've created a view which returns the main table, and columns containing the additional derived data.
I've mapped the view to an entity using the [Table("NameOfView")]
attribute.
It seems to work fine for edits, but inserts fail. Presumably edits don't attempt to touch the derived fields, but inserts attempt to insert them.
Is it possible map entities to views in code first in such a way that a main base table is still updateable, and the columns not intended for updating are ignored?
Or is there another way to do what I'm trying to do?
Note: I've tried to use the [DatabaseGenerated]
attribute but that doesn't appear to have helped...