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

Third-party: EntityFramework.Exceptions: Known exceptions wrapping #90

Open
seclerp opened this issue Jul 12, 2022 · 0 comments
Open

Third-party: EntityFramework.Exceptions: Known exceptions wrapping #90

seclerp opened this issue Jul 12, 2022 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@seclerp
Copy link
Member

seclerp commented Jul 12, 2022

When the project uses EntityFramework.Exceptions, SaveChanges/SaveChangesAsync could lead to exceptions.
E.g.:

context.Posts.Insert(post);
context.{caret}SaveChanges(); // Warning EFXXXX: EF Core state mutatioon could lead to exceptions
context.Posts.Insert(post);

try
{
  context.SaveChanges();
}
catch (UniqueConstraintException ex)
{
  {selstart}throw new NotImplementedException();{selend}
}

The fix should generate exception-catching blocks according to an analysis of the model and context. For example, [UniqueConstraint] or [ForeignKey] attributes could lead to UniqueConstraintException and ReferenceConstraintException respectively.

Full list of currently available exceptions:

  • UniqueConstraintException
  • CannotInsertNullException
  • MaxLengthExceededException
  • NumericOverflowException
  • ReferenceConstraintException
@seclerp seclerp added the enhancement New feature or request label Jul 12, 2022
@seclerp seclerp added this to the Future milestone Jul 12, 2022
@seclerp seclerp changed the title Code: Exceptions wrapping Quick-fix: Exceptions wrapping Jul 12, 2022
@seclerp seclerp changed the title Quick-fix: Exceptions wrapping Third-party: EntityFramework.Exceptions: Known exceptions wrapping Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant