开发者

Convert and modify a model field as an DataColumn object

开发者 https://www.devze.com 2023-04-01 13:23 出处:网络
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 an

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

精彩评论

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