با سلام خسته نباشید خدمت جناب آقای مداینی, من در جلسه ششم دچار مشکل شده ام,زمانی که متد db.savechanges رو از طریق customer.save صدا میزنم , برنامه این ارور را به db.SaveChanges میدهد :
System.Data.Entity.Infrastructure.DbUpdateException
HResult=0x80131501
Message=Unable to update the EntitySet 'Customers' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at System.Data.Entity.DbContext.SaveChanges()
at Accounting.DataLayer.Services.CustomerRepository.Save() in C:\Users\borhani\source\repos\Accounting\Accounting.DataLayer\Services\CustomerRepository.cs:line 76
at ConsoleApp1.Program.Main(String[] args) in C:\Users\borhani\source\repos\Accounting\ConsoleApp1\Program.cs:line 29
Inner Exception 1:
UpdateException: Unable to update the EntitySet 'Customers' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
زمانی که در اینترنت نیز جست و جو کردم گفته شده بود که اگر جدولتان کلید اصلی نداشته باشد این مشکل به وجود می آید,امّا جدول من دارای کلید اصلی است خواهشا من را یاری کنید.
با تشّکر
محمد حسین برهانی
سلام
اگر db first هستید یکبار مدل را پاک کنید و دوبار ایجاد کنید