I created a MVC project using Code First From A Database. I added data annotations to my Model classes, e.g. [DisplayName("Ruling Request ID")] and [ScaffoldColumn(false)].
I selected Add MVC 5 Controller with views, using Entity Framework, selected my Model Class, Data context class, and left Generate Views, Reference script libraries, and Use a layout page checked. All of the files and folders are added correctly.
My problem occurs when I run the app. The index, details, and edit views all display my long property names and not the names I gave the properties using the DisplayName data annotation. Plus, the properties I declared as ScaffoldColumn(false) are appearing on all 3 views.
I'm pasting the code from one of my Model classes below:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
using System.ComponentModel;
[Table("RulingRequest")]
public partial class RulingRequest
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[DisplayName("Ruling Request ID")]
public int RulingRequestID { get; set; }
[StringLength(9)]
[ScaffoldColumn(false)]
public string CreatedBy { get; set; }
[DisplayName("Ruling Request Group ID")]
[StringLength(3)]
public string RulingRequestGroupID { get; set; } //FK
[DisplayName("Type")]
public int? RulingRequestTypeID { get; set; } //FK
[StringLength(50)]
[DisplayName("First Name")]
public string FirstName { get; set; }
I'm a newbie and have searched the interwebs for help, but I haven't come across a similar situation as mine.