none
how to catch the exception when the server is busy in EF6? In EF44 I have used EntityCommandExecutionException RRS feed

  • Question

  • I have a solution with a project with target is net 4.0, but I am using EF6.

    When I installed the nuget package, its was added two reference to the project, EntityFramwork.dll and EntityFramework.SqlServer.dll.

    In other projects in which I have used EF 44, I can catch the exception EntityCommandExecutionException, that is throw when the sql server is busy and can execute the command that is sended from my application. This case is for example when I use a transaction and block some records, one of the users can get this exception because the records that are blocked are not released in any time.

    However, now in EF6 this exception is not avaliable. Is it because that are a new exception? How can catch this kind of exception from the server in EF6?

    I try to add a new reference to the System.Data.Entity, that is a library of .net 4.0, but I thi that this is not a good idea, because if I try to use the EntityState enum I have a conflict because there are two, one in EntityFramework.dll and the other in the System.Data.Entity library.

    Also, really the name space System.Data.Entity is included in EntityFramework.dll without the need of add the reference to System.Data.Entity, so I think that really System.Data.Entity is not needed and is an old version that is not included in an EF6 project.

    So my quiestion is how to catch the exception when the server is busy in EF6?

    Thanks.

    Wednesday, November 27, 2013 4:45 PM

Answers

  • Hello,

    The namespace has been changed from System.Data.Entity.dll to System.Data.Entity.Core.dll, so it will be not helpful to add a reference to this assembly.

    For catching exceptions in entity framework 6, we also use EntityCommandExecutionException class and we need to use System.Data.Entity.Core namespace.

    For the details, see it here.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 28, 2013 7:22 AM
    Moderator