In an MVC application I'm using Entity Framework for this simple model:
public class Product
{
public Guid ProductID { get; set; }
[Required]
[StringLength(50, MinimumLength = 1)]
[Display(Name = "Product name")]
public string ProductName { get; set; }
[Required]
[Display(Name = "Download URL")]
[DataType(DataType.Url)]
public string DownloadUrl { get; set; }
[Display(Name = "Download counter")]
public int DownloadCounter { get; set; }
}
I've have scaffold pages for this automatically and have two questions:
- Is there a way to mark the DownloadCounter property so it's not visible on the edit/create page. Deleting it manually is no major problem but I'm curious.
- When I'm updating the product from an edit page I don't want to change the value on the Download counter. Is there any way to that? Currently I'm losing data if I manually change the DownloadCounter value in the database when I'm inside the edit page. I assume I could use stored procedures (there is a nice description here http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/async-and-stored-procedures-with-the-entity-framework-in-an-asp-net-mvc-application), but want to know if there are alternative ways to deal with this.