ASP.NET MVC > Models

Mapping model property to database field in ASP.NET MVC

How to give a meaningful name to the model property and still map with the database table field?


To do this, we can use Column attribute in the Model property. 

[Column("Active")] 
[Display(Name = "Is Active?")]
public bool IsActive { get; set; }

Here, the model property name is the IsActive however we are mapping this property to the Active field of the database table. 

 Views: 18503 | Post Order: 39



Write for us






Hosting Recommendations