c# - Updating EF model created using code first approach -


i working on project uses ef created code first approach. model created else. in database table there no primary key , fields mandatory. need column auto incremented primary key , column optional. have made these changes in database table getting 'entity validation error' since not passing "id"(probably reason). changes , should written? here class created:

public int id { get; set; }//this needs auto incremented primary key. public int userid{ get; set; } public string name { get; set; } public string address { get; set; } public bool isactive { get; set; } public bool deleted { get; set; } public int modifiedby { get; set; } public system.datetime datecreated { get; set; } public system.datetime datemodified { get; set; }//this field needs optional. 

you need set key , databasegenerated attributes new id property.

[key] [databasegenerated(databasegeneratedoption.identity)] public int id { get; set; } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -