开发者

Convert and modify a model field as an DataColumn object

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; }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜