Using Telerik OpenAccess ORM I have 2 objects User
and Investment
. More specifically Investments
contains a foreign key to User
as any typical one to many relationship. In other words each User can have mutliple Investments but each Investment can only have one user.
I have then attempted to utilize the open access feature 'Is Managed'
Which should mean that I can do something like User.Investments.Clear();
and it deletes all the related investments (or at least this works fine in many-to-many relationships) but unfortunately when I attempt this I am greeted with the following error.
"Update failed: Telerik.OpenAccess.RT.sql.SQLException: Cannot insert the value NULL into column 'UserID', table 'CODECorp.dbo.Investment'; column does not allow nulls. UPDATE fails."
Clearly what the ORM is trying to do is remove the association (i.e. foreign key) from the investment object to the user rather than deleting it. I have confirmed this by running SQL profiler and can see that it's running an Update
rather than a Delete
.
So what am I missing here? Why is it incorrectly trying to remove the association rather than simply deleting the row as you would expect?