-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
DeleteBehaviorAttribute
#9621
Comments
DeleteBehaviorAttribute
data annotations DeleteBehaviorAttribute
see also in #10864 |
Hey, I've wanted to take on the challange of implementing this. As far as I understand I should create DeleteBehaviorAttribute class in EFCore.Abstractions taking DeleteBehavior parameter in constructor (for now I've used int as I have trouble getting DeleteBehavior usings to EFCore.Abstractions) and storing it as a property. Could someone explain to me also how could I reference DeleteBehavior enum from inside of EFCore.Abstractions? |
@Vekz Sounds like a good plan. For the enum, move it to Abstractions and add type-forwarding to avoid a breaking change. For an example, search for |
Okay, I've finished writing tests and figuring out how to put everything I've learned in past day so every case works. Only this enum's left for me to implement. I'm gonna make PR probably later today. Thanks for really fast reply and pointing me to the solution. |
I didn't think I would get so much trouble from this TypeForwarding. I get CS0012 on tests that build models from snapshot after I've done TypeForwarding. Sorry if it's stupid question this is actually first time I've ever touched TypeForwarding. Update: I just added EFCore.Abstractions assembly reference in Bases for snapshot and migration tests and it fixed it |
@ajcvickers Could I ask you for a CR? |
Fixes #9621 Added: DeleteBehaviorAttribute - Stores DeleteBehavior set on the property. DeleteBehaviorAttributeConvention - Triggers on ForeignKeyAdded, checks if its navigation has DeleteBehavior. If so then sets DeleteBehavior of this foreign key. Moved: DeleteBehavior => EFCore.Abstractions and added TypeForward in EFCore
DeleteBehaviorAttribute
DeleteBehaviorAttribute
Data annotations is a much easier way to configure model than Fluent API.
And we can only configure
DeleteBehavior
via Fluent API today, that means we need configure foreign key again in fluent api.Can we have a
DeleteBebaviorAttribute(DeleteBehavior behavior)
inMicrosoft.EntityFramework
Namespace ?The text was updated successfully, but these errors were encountered: