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