ASP.NET MVC 2 - "The model of type 'XYZ' could not be updated" when using UpdateModel and LINQ to Entities (.NET 3.5)

Managed to solve the problem. Can be done in one of two ways:

TryUpdateModel(original)

or

db.ApplyPropertyChanges(original.EntityKey.EntitySetName, xyz)

No idea why TryUpdateModel will work but UpdateModel won't. Maybe just a bug in .NET 3.5.


what I do in my MVC projects is grab the source code for the DefaultModelBinder from Codeplex and paste it into a new class in your project, like MyDefaultModelBinder. then register that model binder in your global.asax:

ModelBinders.Binders.DefaultBinder = new MyDefaultModelBinder();

this lets you set a breakpoint in the BindModel method, and you can figure out why it's not able to bind.