Skip to content
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

Add ForeignKeyConstraint to the relational model. #20141

Merged
merged 1 commit into from
Mar 4, 2020
Merged

Conversation

AndriySvyryd
Copy link
Member

Part of #12846

Copy link
Member

@smitpatel smitpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also update your images from presentation to demonstrate where do ForeignKeyConstraint fit in those charts.

Comment on lines 351 to 357
case DeleteBehavior.ClientNoAction:
return ReferentialAction.NoAction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this wrong? The store should restrict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍
@ajcvickers Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this PR change this? (I don't remember the mappings off the top of my head.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajcvickers No, this is what we have right now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's probably what we decided. Whether or not it is "correct" is a different question.

Copy link
Member Author

@AndriySvyryd AndriySvyryd Mar 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR: It doesn't matter

It's a bit confusing (as expected): for EF ReferentialAction.NoAction means use the database default and in most databases NoAction is the default. In most databases NoAction doesn't mean that no error is thrown, it means that the error is delayed until the transaction is committed. Also in SQL Server there's no Restrict.

EF currently doesn't support deleting and inserting the same (principal) row in a single transaction, so NoAction and Restrict are equivalent, but if we ever do then NoAction would be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine to leave as is for now, but I want to do a deep review of these. I remember Diego and I really wanted to break something here.

src/EFCore/Metadata/IForeignKey.cs Outdated Show resolved Hide resolved
@AndriySvyryd
Copy link
Member Author

Can you also update your images from presentation to demonstrate where do ForeignKeyConstraint fit in those charts.

I don't think it's worth it, it's mostly IForeignKey.GetConstraintMappings() <*-*> IForeignKeyConstraint.MappedForeignKeys. The other aspects are straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants