Version: DataObjects.Net v4.3.0 (build 5605) for .NET 4.0 DB Engine: MS SQL Server 2008
Have this model:
In entity class Car i have defined association like this:
As i read manual then setting OnTargetRemove = OnRemoveAction.Cascade means that when person is removed than all associated cars with this person is also removed, right?
Removing person from C# code also removed associated cars, which is OK. But when i look at generated SQL foreign key in table "Cars" then this foreign key has set action "On Delete" to value "NO ACTION" which is wrong, there should be value "Cascade" like defined in code in association attribute, isnt?
Updated at 28.07.2010 18:13:48
I thought that, but is this right? Is there any reason why it is not also on DB foreign key?
This thread was imported from our support forum. The original discussion may contain more detailed answer.
The only reasons is that this adds additional (and significant) complexity, which is mostly unnecessary: we must consider implicit cascade removals in:
Actually, the simplest possible implementation of this is to ensure we do all the cascade removal by our own before DB (nearly this anyway happens now), and let DB do nothing. So we'll consider implementing this, but as far as I can judge, this is pretty low priority issue.
I tend to view on schema-related features from two different angles: 1) Necessity in standard mode. Here DO4 handles everything. Our goal is to ensure you can implement 99% of tasks relying on DO so that implementation provides nearly the same performance as in case with your own schema. If you work with schema directly in this case, it is untypical (= we don't pay much attention to this, but taking this into account). Upgrade is also mainly our own problem. 2) Necessity in legacy mode. Here you provide the schema, and our goal is to map entities to it. Currently we don't support such features as views and IDENTITY columns, but the final goal is to support them + stored procs at least. Since schema is provided by you, upgrade isn't our problem.
So my classification of this issue is based on case 1) - likely, it's just a pleasant option.
answered Jul 28 '10 at 20:06