In ASP.NET MVC 3 I would like to access at database creation time the model fields as if they were objects of DataColumn class, so that I could then modify the auto-incremen开发者_开发百科t setting and store it back.
My primary target is to disable the auto-incrementing (identity setting) on the primary key of a model using code first approach.
This might what you need
public class MyModel
{
[Key]
[DatabaseGenerated(System.ComponentModel.DataAnnotations.DatabaseGeneratedOption.None)]
public int MyID { get; set; }
}
精彩评论