我正在尝试实体框架的模型优先方法。我是 Entity Framework 的新手,从这里学习并以相同的方式编码。但我收到了这个错误
Unable to update the EntitySet 'Users' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
我正在运行的代码是:
protected void Page_Load(object sender, EventArgs e)
{
User use = new User();
use.First_Name = "Arslan";
use.Last_Name = "Akbar";
use.Password = "alone";
use.Email = "arslan@gmail.com";
use.Designation = "Head";
using (CustomersEntities ce = new CustomersEntities())
{
//int count = ce.Users.Count();
//count++;
// use.Id = count;
ce.Users.Add(use);
ce.SaveChanges();
// ce.Users.Create(use);
// ce.SaveChanges();
//ce.Entry(use).State = System.Data.EntityState.Added;
}
}
我无法确定问题所在。