Hola amigos estoy tratando de hacer un Insert con Entity Framework, pero tengo cuando quiero hacer el Add obtengo esto error.
Unable to update the EntitySet 'HomeCounters' because it has a DefiningQuery and no element exists in the element to support the current operation.
Justo aquí.
db.SaveChanges();
Este error me manda cuanda hago el id auto incrementable
System.Data.Entity.Infrastructure.DbUpdateException: 'Unable to update the EntitySet 'HomeCounters' because it has a DefiningQuery and no element exists in the element to support the current operation.'
Este es mi código, alguien sabe a que se deba?
[Authorize]
[HttpPost]
public ActionResult InsertCounters(string id_userCreated, string texto, string value)
{
using (DBEnt db = new DBEnt())
{
var counter = new HomeCounters()
{
text = texto,
value = value,
id = RandomNumber(1, 1000000000)
};
db.HomeCounters.Add(counter);
//db..add(cat);
db.SaveChanges();
}
var action = "Insert";
var comments = "Contadores ingresada por el usuario : ";
InsertInBitacora(id_userCreated, action, comments + id_userCreated);
return View("Index");
}
Esta es la clase que estoy usando
public partial class HomeCounters
{
public int id { get; set; }
public string text { get; set; }
public string value { get; set; }
}
HomeCounters
?