Dear All,
I am trying to delete an "AttendeeEvent" from the database with EF4, however I am getting the following error:-
The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.
My code is as follows :-
public void UnRegisterCurrentUserForEvent(int eventId)
{
Attendee attendee = GetOrCreateAttendeeForCurrentUser();
AttendeeEvent av = attendee.AttendeeEvents.SingleOrDefault(x => x.EventID == eventId);
if(av != null)
{
attendee.AttendeeEvents.Remove(av);
}
this.ObjectContext.SaveChanges();
}
I tried to change the End 2 On Delete from the properties in the .edmx however when I set to cascade, I am getting an error:-
Error 1 Error 132: cannot have operation specified since its multiplicity is ''. Operations cannot be specified on ends with multiplicity ''
Can you guys help me out
Thanks for your help and time