DCSIMG
Unable to update the EntitySet '[TableName]' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation - שלמה גולדברג (הרב דוטנט)

שלמה גולדברג (הרב דוטנט)

מרצה בסלע ויועץ בעולם ה - net.

Unable to update the EntitySet '[TableName]' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation

 

היה לי בבסיס הנתונים קישור פשוט של רבים לרבים
many to many
 
 
מבחינת האובייקטים ב - Entity Framework זה נוצר בצורה הזאת
 
EF - many to many
 
 
הקשר בין הרצאה לתגים הוא רבים לרבים. כשניסיתי לכתוב את הקוד הזה
 
 

Lecture lecture = entities.Lectures.First();

Tag tag = new Tag() { Name = "acbd" };

lecture.Tags.Add(tag);

 

entities.SaveChanges();

 
קבלתי את ההודעה הבאה
 
 
Unable to update the EntitySet 'TagLecture' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation
 
 
התחלתי לחקור את הנושא ופתחתי את קובץ ה - xml שה - EF מייצר.
 
וראיתי את ההודעה הבאה
 
 <!--Errors Found During Generation:
      warning 6002: The table/view 'SCO.dbo.TagLecture' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
 
מסתבר שלא היה בטבלת הקשר TagLecture אף מפתח ראשי. הגדרתי את שני העמודות כמפתח ראשי רפרשתי את המודל והכול בא על מקומו בשלום

תוכן התגובה

שוהם כתב/ה:

תודה!! עזר לי...

# May 22, 2012 3:46 PM
שלח תגובה

(שדה חובה)  

(שדה חובה)  

(אופציונלי)

(שדה חובה) 

Please add 4 and 2 and type the answer here:


Enter the numbers above: