-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CASCADE verbs #148
Comments
I saw in your ForeignKeyStatementBuilder.cs you have only the CascadeVerb (always on). Something like:
|
You don't do anything wrong. This isn't supported by the Entity Framework and therefore also not by this library. A custom attribute could easily be implemented of course. However, I try to do this as little as possible. Can you elaborate on your use case? |
Lets make a real example. This is an extract for my entities: [Table("t_works")]
...
} [Table("t_works_event")]
} This is an extract of the original DB I've used (created by hand): (this table has an independent rowid) ... (this table has no rowid) ... PRIMARY KEY([ref_id_work], [type], [insert_timestamp] ASC)) WITHOUT ROWID; This is the output for a created DB with your library: CREATE TABLE "t_works" ( ... CREATE TABLE [t_works_event]( ... PRIMARY KEY([ref_id_work], [type], [insert_timestamp] ASC)); As you can see there are some differences between the original and the generated versions:
So if I update (change the value) of the "id" field (that is not the real id because of the rowid) in my "work" entity, the change is not propagated through all the child elements of "work_events". My suggestion is to add two attributes: one for rowid (not strictly necessary) and one for drive delete/cascade verbs in code fisrt. The second could be a derived class from ForeignKeyAttribute. Lorenzo |
`` Sent with GitHawk |
Thanks for your explanations. I'm okay with having these custom attributes. Feel free to open a PR. Please take care that no breaking change occurs and to add corresponding unit tests & integration tests. |
HI, I'm exepriencing an issue with foreign key triggers.
After database creation only the ON DELETE CASCADE Keyword is present. The key ON UPDATE CASCADE is missing.
I'm using the System.ComponentModel.DataAnnotations.Schema ForeignKeyAttribute (which doesn't provide any other options).
Do you think I'm doing something wrong?
The text was updated successfully, but these errors were encountered: