Reputation: 415
I have a 'users' and 'notifications' tables. The tables definition are:
users notifications
------- -------------
ID (PK) ID (PK)
Name Name
users_ID (FK / Relation)
When I do:
MyUserEntity.notifications.clear();
MyContext.SaveChanges();
The users_ID column value(s) for the corresponding user entity are set to NULL, but I want the rows to be deleted.
What am I missing? Thanks!
Upvotes: 0
Views: 391
Reputation: 109027
Try
foreach(var notification in MyUserEntity.notifications.ToList())
{
MyContext.DeleteObject(notification);
}
MyContext.SaveChanges();
Upvotes: 1