rider-efcore
rider-efcore copied to clipboard
Third-party: EntityFramework.Exceptions: Known exceptions wrapping
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