I have created a database in SQL Server and have used Entity Framework to create a model in my C# MVC 5 project. In my models I am using System.ComponentModel to give a DisplayName to several properties (or columns). Example:
namespace ProjectTracking.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
public partial class EmployeeType
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public EmployeeType()
{
this.Employees = new HashSet<Employee>();
}
[DisplayName("Employee Type ID")]
public int PK_EmployeeTypeID { get; set; }
[DisplayName("Employee Type Name")]
public string EmployeeTypeName { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Employee> Employees { get; set; }
}
}
The problem that I've run into is that, if I update the database and update my model, I lose all of this information as all of the model classes are regenerated. Is there a way to persist this information?