I know this question has been asked/answered but I can't find it for the life of me.
I am creating and ASP.NET MVC 3 app with an existing db but wanted to go code first so I'm used the EF Power Tools CTP1 to get me started. Ultimately, I will refactor to a better solution but to get going I used the MVCScaffolding to gen up controllers and views. I'm struggling with creating a display value (FullName) property on my model that is a combination of the FirstName and LastName columns in the DB.
I have a simple class
public class Manager
{
public Manager(){}
public int ManagerID { get; set; }
[DisplayName] // Not in db.. want to populate this from first & last name
public string FullName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
and a mapping file that looks like
public ManagerMap()
{
// Primary Key
this.HasKey(t => t.ManagerID);
// Table & Column Mappings
this.ToTable("Manager");
this.Property(t => t.ManagerID).HasColumnName("ManagerID");
this.Property(t => t.FirstName).HasColumnName("FirstName");
this.Property(t => t.LastName).HasColumnName("LastName");
this.Property(t => t.Email).HasColumnName("Email");
this.Property(t => t.FullName).WhatToDo..? //<-- Can I / how does this mapping look
}
}
Is it possible to create the FullName mapping or am I going about this the entirely wrong way?