locked
after server reboot Entity Framework services give "The login failed" exception in System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf RRS feed

  • Question

  • Hi,

    we have a windows service using Entity Framework 4. Normally this works fine. After a server reboot this fails due to the exception: "The login failed" in System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(). I have moved the service to be on the same machine as the SQL Server and with depency on SQLServer service. This has not solved the problem. Call stack below.

    To overcome this issue I simply have to restart the service. This is obviously not an acceptable resolution. I assume that this is a timing issue. I have tried putting a 10 second delay into the service OnStart() but this doesn't help.

    All help gratefully received

    Kind Regards

    Paddi Stowe

    Exception Call Stack:

    Exception message;The underlying provider failed on Open.

    Inner exception;

    Cannot open database "DBName" requested by the
    login. The login failed.

    Login failed for user 'domain\svcAccount'.

    Stack trace;

       at
    System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean
    openCondition, DbConnection storeConnectionToOpen, DbConnection
    originalConnection, String exceptionCode, String attemptedOperation, Boolean&
    closeStoreConnectionOnFailure)

       at
    System.Data.EntityClient.EntityConnection.Open()

       at
    Comp.Brand.EventProcessor.Service.get_Entities()

       at
    Comp.Brand.EventProcessor.Service.GetCompany()

       at
    Comp.Brand.EventProcessor.Service.OnStart(String[] args)


    pstowe

    Friday, March 23, 2012 8:41 AM

Answers

  • Hi Paddi Stowe,

    Welcome to MSDN Forum.

    Based on the issue, if the project can't connect to the database only after reboot the server, and restart the service can solve it, I think the problem is caused by windows server, not EF. If it caused by EF connection string, no matter whether you restart the service, the login will always fail.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Allen_MSDN Friday, March 30, 2012 2:23 AM
    • Marked as answer by Allen_MSDN Monday, April 2, 2012 1:27 AM
    Monday, March 26, 2012 6:07 AM