0

I'm trying to run my application in localhost. But I always get "EntityException-The underlying provider failed on Open" - All the static pages are working.

Same application if I use VS2017 to run application is working fine. (Able to retrieve data from DB)

Is it anything to do with the Connection String?

Here's my connection string:

<add name="NaturesKingdomUKEntities" connectionString="metadata=res://*/Models.DB.NaturesKingdomUK_DB.csdl|res://*/Models.DB.NaturesKingdomUK_DB.ssdl|res://*/Models.DB.NaturesKingdomUK_DB.msl;provider=System.Data.SqlClient;provider connection string=&quot;
         data source=xxx-xxx;initial catalog=xxxx;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
         providerName="System.Data.EntityClient" />

Sample method that I use to get data from db:

    public List<ProductDetails> GetFineFragrancesProductDetails(string ProductCodeID)
    {
        try
        {
            using (xxxxEntities db = new xxxxUKEntities())
            {
                //db.Connection.Open();
                if (ProductCodeID == "All")
                {
                    var queryList = db.ProductInfoes.ToList();                       
                    UpdateProductDetailsList(queryList);
                }
                else
                {
                    var queryList = db.ProductInfoes.Where(x => x.Product_Code_ID.Equals(ProductCodeID)).ToList();

                    UpdateProductDetailsList(queryList);
                }
                return lst;
            }
        }
        catch (Exception err)
        {
            SendErrorToText(err, "DB - GetFineFragrancesProductDetails");
            return null;
        }
    }

Exception Details:

Error Message: EntityException

Exception Type: System.Data.EntityException

Error Url: http://xxxx.local/xxxx/FineFragrxances

User Host IP: 127.0.0.1

Error Location : The underlying provider failed on Open.

Community
  • 1
  • 1
Albion
  • 31
  • 1
  • 8
  • I think your pastes have gone wrong. – Thom A Nov 22 '19 at 18:37
  • Can you copy the webconfig with visual studio 2017 to iis application folder – Nayas Subramanian Nov 22 '19 at 19:14
  • There is a very active and highly viewed discussion on this error message over here: https://stackoverflow.com/questions/2475008/mssql-error-the-underlying-provider-failed-on-open. It looks like the problem could be any number of things. If you try all the solutions over there, and none of them work, then come back here and update your OP with what you've tried and what the results were. – Casey Crookston Nov 22 '19 at 19:58
  • Have you copied and pasted the connection string from somewhere? Create the EntityFramework connection from Visual Studio and try.. – JayNaz Nov 25 '19 at 11:44
  • allowed entity framework to update the web.config and then copied the same config file fromthe source folder to IIS website folder – Albion Nov 26 '19 at 11:18

0 Answers0