1
我正在尝试将新的Person
保存到数据库。我的代码编译得很好,但是当我运行它时,我在.Add()
处得到一个错误。无法使用“.Add()”插入新的实体框架实体
错误说, “This EntitySet of Type 'Diavik.DataAccess.Person' does not support the 'Add' operation.
”
这是一个Silverlight应用程序,这文件是App.xaml.cs
。
这里是我的代码:
private void OnGetPerson_Completed(LoadOperation<Person> operation)
{
Person person = operation.Entities.SingleOrDefault();
if (person == null)
{
person = new Person()
{
FirstName = WebContext.Current.User.FirstName,
LastName = WebContext.Current.User.LastName,
IlluminatorLogin = WebContext.Current.User.Name
};
Context.Persons.Add(person);
}
Context.SubmitChanges(submitOp =>
{
// Some Stuff
}, null);
}
感谢你的帮助,
亚伦
你的域名服务是怎样的?你有'[Insert]'方法吗? – nemesv