I have two tables, Property and PropertyMeta. They are linked by the PropertyID value. I have just started using ASP.net MVC and am currently using MVC2 (due to hosting provider contraints). From a simple create page i am trying to populate both tables but i'm not having much luck at all.
[HttpPost, Authorize]
public ActionResult Create(PropertyViewModel property)
{
try
{
MyEntities db = new MyEntities();
Property _property = new Property();
_property = property.Properties;
PropertyMeta _meta = new PropertyMeta();
_meta.Property = _property;
_meta = property.Meta;
db.AddToProperties(_property);
db.AddToPropertyMetas(_meta);
db.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
I have tried the above but it isn't working. It's annoying, this should be so simple but i'm stuck. Can anyone think what might be wrong with the above? Any help would be greatly appreciated!