I'm using ValueInjecter to inject data from my view model to my entity framework model, and for non Ids such as strings it works great. For some reason it is not mapping the IDs from select lists in my view, once mapped they show up as null. Any ideas why?
[HttpPost]
public ActionResult Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
//inject the view model into db model
Core.Models.User user = new User();
user.InjectFrom(model);
View Model
[Required(ErrorMessage = "Organization is required")]
[DisplayName("Organization")]
public Guid OrganizationId
{ get; set; }
Entity framework model Property
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public Nullable<global::System.Guid> OrganizationId
{
get
{
return _OrganizationId;
}
set
{
OnOrganizationIdChanging(value);
ReportPropertyChanging("OrganizationId");
_OrganizationId = StructuralObject.SetValidValue(value);
ReportPropertyChanged("OrganizationId");
OnOrganizationIdChanged();
}
}