none
Connection String does not work only in azure

    Question

  • When i try deploy my web app i get this error:

    Server Error in '/' Application.
    
    The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.


    I try change de connection string repeatedly but nothing works. When i try access the sql database in "azure server" from my local application everything works. Then the connection string reported is correct but does not work.
    Thursday, August 01, 2013 1:50 PM

Answers

All replies

  • Hi,

    I saw this error some other time... I think it is related to this:

    http://social.msdn.microsoft.com/Forums/en-US/f5904b4d-b2f8-421e-90de-339f93959533/entityconnection-error-the-specified-named-connection-is-either-not-found-in-the-configuration

    In short, you have to copy the connection string in the proper section of web.config.


    Thursday, August 01, 2013 2:58 PM
  • Thanks for help!

    How do this? I already setup de connection string in my WebUI app. In this case, i need input other section under which name app?

    My Web.Config

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=152368
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      
      <appSettings>
        <add key="webpages:Version" value="1.0.0.0" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
      </appSettings>
      <system.web>
        <customErrors mode="Off">
        </customErrors>
        <sessionState mode="InProc" timeout="20"/>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </assemblies>
        </compilation>
        <authentication mode="Forms">
          <forms loginUrl="~/Account/LogOn" timeout="2880" />
        </authentication>
        
        <membership defaultProvider="CustomMembershipProvider">
          <providers>
            <clear/>
            <add name="CustomMembershipProvider" type="CloudWork.WebUI.Infrastructure.CustomMembershipProvider"/>
          </providers>
          
        </membership>
        
        <roleManager cacheRolesInCookie="true" enabled="true" defaultProvider="CustomRoleProvider">
          <providers>
            <clear/>
            <add name="CustomRoleProvider" type="CloudWork.WebUI.Infrastructure.CustomRoleProvider"/>
            
          </providers>
          
        </roleManager>
        
        <pages>
          <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
          </namespaces>
        </pages>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
      </entityFramework>
      <connectionStrings>
        
        
        <add name="CadastrosEntities" connectionString="metadata=res://*/Concrete.CloudWork.csdl|res://*/Concrete.CloudWork.ssdl|res://*/Concrete.CloudWork.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=XXXX.database.windows.net;initial catalog=XXXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        
    
      </connectionStrings>
     
    </configuration>

    Thursday, August 01, 2013 3:49 PM
  • Do you have an app.config file with the expected content is in the directory where the exe is compiled?

    Did you try to change &quot; into a single quote in the connection string?

    Thursday, August 01, 2013 4:00 PM
  • Yes, i have other project in the same solution with app.config. Looking in ftp folder, i dont see the app.config.

    Change the &quot; had no effect.

    Thursday, August 01, 2013 4:14 PM
  • As mentioned in the above link, the app.config must be in the path where is the exe file...

    Maybe this is a bug of Visuali Studio, what version are you using?

    Thursday, August 01, 2013 4:23 PM
  • Visual Studio 2010 SP1. I copied the app.config to App_Data folder, and the error continues.

    The connection string is correct because the local app gets de data from web sql.
    Thursday, August 01, 2013 6:37 PM
  • The correct app.config should be in all folder of all applications involved.

    Did you check the app.ccnfig?


    • Edited by dsmwb Thursday, August 01, 2013 7:33 PM
    Thursday, August 01, 2013 6:55 PM
  • This resumed all attempts:

    1° The connection string in app.config and web.config

    <connectionStrings xdt:Transform="Replace">
    
        <add name="CadastrosEntities" connectionString="metadata=res://*/Concrete.CloudWork.csdl|res://*/Concrete.CloudWork.ssdl|res://*/Concrete.CloudWork.msl;provider=System.Data.SqlClient;provider connection string='data source=XXX.database.windows.net;initial catalog=XXX;persist security info=True;user id=XXX;password=XXX;multipleactiveresultsets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
        
      </connectionStrings>

    2° Check the &quot to ( ' ).

    3° Copy the app.config from Class Library to App_Data and bin folder in WebUI MVC 3.

    4° Test the local connection with the web sql, works fine.

    But, the same error when I deploy the app continues.

    Nice ham? hehe


    Thursday, August 01, 2013 7:29 PM
  • Post the stack trace, it could be illuminating...
    Thursday, August 01, 2013 7:39 PM
  • First, thank you so much for your effort ... I'm blind and all help is welcome.

    The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

    [ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.]
       System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +8498285
       System.Data.EntityClient.EntityConnection..ctor(String connectionString) +43
       System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString) +85
       CloudWork.Domain.Concrete.CadastrosEntities..ctor() +16
       DynamicInjectorc995a89c11fc4752a7193f06954f5ebc(Object[] ) +55
       Ninject.Activation.Providers.StandardProvider.Create(IContext context) +487
       Ninject.Activation.Context.Resolve() +184
       Ninject.<>c__DisplayClass10.<Resolve>b__c(IBinding binding) +30
       System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
       System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4078845
       Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) +89
       Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) +334
       Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) +152
       Ninject.Activation.Providers.<>c__DisplayClass4.<Create>b__2(ITarget target) +17
       System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
       System.Linq.Buffer`1..ctor(IEnumerable`1 source) +216
       System.Linq.Enumerable.ToArray(IEnumerable`1 source) +77
       Ninject.Activation.Providers.StandardProvider.Create(IContext context) +474
       Ninject.Activation.Context.Resolve() +184
       Ninject.<>c__DisplayClass10.<Resolve>b__c(IBinding binding) +30
       System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
       System.Linq.Enumerable.Single(IEnumerable`1 source) +191
       CloudWork.WebUI.Infrastructure.NinjectControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +66
       System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
       System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +196
       System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +49
       System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +13
       System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
       System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
       System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +88
       System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
       System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


    Thursday, August 01, 2013 7:46 PM
  • Hi Douglas,

    From my experience, since you're using Windows Azure SQL Database, if the connection string works in your local environment, it would also work in the cloud. You mentioned you're using website, then the app.config may not be needed, a web.config is needed, and please make sure it is put under the root folder of your site. Also it would be better if you can double check whether the web.config file is exactly the same as your local version.

    Best Regards,

    Ming Xu


    Ming Xu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, August 04, 2013 9:56 AM
    Moderator