i am getting this error SqlException: Cannot insert explicit value for identity column in table 'Ogretmenler' when IDENTITY_INSERT is set to OFF. Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action wrapCloseInAction)
DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection
what should i do?
here is my code
[HttpGet]
public IActionResult Create()
{
List<SelectListItem> value = (from Ders in _db.Dersler.ToList()
select new SelectListItem
{
Text = Ders.DersName,
Value = Ders.Id.ToString()
}).ToList();
ViewBag.v1 = value;
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(Ogretmen obj)
{
if (ModelState.IsValid)
{
_db.Ogretmenler.Add(obj);
_db.SaveChanges();
return RedirectToAction("Index");
}
return View(obj);
}