I cannot understand how the navigation properties for my model (EF4) will not be empty after posting. I have the same problem on several main pages.
i.e. I have a Rate table with the LoginID foreign key (from the login table).
In my HTTPGet editing method, I find the specific rating I want:
Estimate estimate = db.Estimates.Find(id)
From here I can access the login properties and any properties of this entry from the login table.
I pass this estimate as a model for my strongly typed view. When my HTTPPost Edit method is called (and the model is passed to it as a parameter), my login navigation property is null, and I cannot access it. I can get around this, of course, because I have a LoginID field in my evaluation class, but it feels very awkward and as if I overlook the key advantage of an entity structure.
I have the same problem on multiple pages where I pass a model with a navigation property to my view and the view returns a model with a null navigation property.
Below is an example of the code I encountered with the problem:
[HttpPost]
public ActionResult Edit(Estimate estimate)
{
var test = estimate.Login.CompanyProfileID;
...
Model.Login, , , . , .