Hello,
i am working on an MVC application and have used EF. [Database first approach].
I created Scaffold Template from EF. I have 2 tables tblEmployee and tblDepartment. Changed their name in edmx designer to Employee and Department.
Now when i go to index view which shows me all the employees there are two columns with name "Name" , one for employee and one for department. So now i want to change the Column name "Name" for department to "Department Name".
As i am using DB first approach can't do the changes in DataModel.Designer.cs
SO i created a partial class Department [ name is same as in Designer.cs]
decorated it with MetaDataType attribute and passed a class with name property to the type parameter.
All good till now. But now when i run the project i don't see the changes in the Index view. don't know what to do now.I am New to MVC. any sort of help is much appriciated !!!
What I have tried:
This is the new partial class that i created
[MetadataType( typeof(DepartmentMetaData))]
public partial class Department
{
}
public class DepartmentMetaData
{
[Display(Name = "Department Name")]
public string Name { get; set; }
}
this is the property in DataModel.Designer.cs
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public global::System.String Name
{
get
{
return _Name;
}
set
{
OnNameChanging(value);
ReportPropertyChanging("Name");
_Name = StructuralObject.SetValidValue(value, true);
ReportPropertyChanged("Name");
OnNameChanged();
}
}
so the name of the property matches and there is a partial class . It should now change the name while showing records but it isn't. Please tell me if i missed something.