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 Activefield of the database table. 

No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...