From what I remember, you will either need to attach the object again to the context and set it as modified Or reload the object from the database and apply your changes. This article explains it better: msdn.microsoft.com/en-us/magazine/ee3215... What version of EF are you using?
Database work should be put in the repository call. Are you directly binding to an entity framework object in your model binding? If not, you should consider do some mapping between your custom object and entity framework object.
My db calls are in repository. What I'm trying to find out is when to call them to best leverage EF. As far as your question goes, I'm trying to determine that with these questions.It looks like I best use EF if I model bind querying the EF object early so it can use concurrency and better track state.
– RailRhoad Dec 29 '09 at 16:36 I wouldn't expose the EF object directly to "model binding", I will use my own domain object or DTO, and map those object onto the EF object. – J.W.Dec 29 '09 at 18:38.
If an EF object has been created outside a context, you need to Attach the object to the context. See: msdn.microsoft.com/en-us/library/bb89627....
– RailRhoad Dec 29 '09 at 16:29 Plus, attaching an object to the context leaves it an unchanged state. Wouldn't I want to query it first (before the model binding) and let it bind then. Then it could properly determine the state right?
– RailRhoad Dec 29 '09 at 16:33 The Attached object will be a new object, if you want to update an existing object, you need first to get it from the database, make the changes and then save the changes. – Shiraz Bhaiji Dec 29 '09 at 16:57.
Based on my observations using VS 2012, MVC 4 and EF 4.0 with a view that has an EF object for a model that submits a form back to the controller. "data" will only have the properties used in the view (@Html. It appears that when "data" is created, the posted FormCollection is used to set data's properties.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.