Problem :
If I make STOREGENERATED PATTERN = NONE Record is inserted in my database once with ID =0. After that it gives error so I change it to identity
I wanted to automatically generate primary key. I created a new project made it Identity
public partial class USER { [key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int ID { get; set; } public string NAME { get; set; } }
Controller
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(USER obj)
{
using( var db = new Entities() )
{
var u = new USER();
u.NAME = obj.NAME;
db.USERS.Add(u);
db.SaveChanges();
}
return View();
}
ERROR!
I search on the internet but could not make it work. --> I want my project to automatically create Primary key of tables. I am using Oracle SQL database and Entity framework 5.0.0