Best practice to handling exceptions of ef core in asp.net project?

entity-framework-core exception repository-pattern

Question

i use ef core 2.1 in asp.net core mvc project.i also use repository pattern to access database.

ISSUE:

i want show some exceptions(e.g foreign key constraint fails) with ajax to user and other exceptions svae in log file of my program.by applying DRY method to avoid use try....catch repeated blocks in my code

how can do it? thanks..

1
0
9/13/2018 7:06:10 AM

Popular Answer

You can use AOP ( Aspect Oriented Programming ) or custom middlewares in asp.net core for cross-cutting concerns like exception handling and logging.

0
9/15/2018 8:11:00 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow