0

Provided Error

No connection string named 'Entities' could be found in the application config file.

enter image description here


Explanation and Inquiry

I know this question has been asked, but I have found that none of the answers are working for me, and I believe it has to do with my attempts to Scaffold on Root > Areas > BlogPage. That said, I am still new to backend development, so I could be missing something very obvious.


Folder Hierarchy

Folder Hierarchy, adding scaffolding to subfolder.


Add New Scaffolding Input Values

Right Click, Add New, Add Scaffolding View, Input Values


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=301879
  -->
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="JosephMCasey.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
    
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Server=tcp:AZUREDB.database.windows.net,1433;Database=AZUREUSER_db;User ID=AZUREUSER@AZUREDB;Password=PASSWORD;Trusted_Connection=False;Encrypt=True;Connection Timeout=30" providerName="System.Data.SqlClient" />
    <!--  configSource="config\ConnectionStrings.config" -->
  </connectionStrings>
  <appSettings file="config\AppSettingsSecret.config">
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" />
    </httpModules>
    <customErrors mode="RemoteOnly" redirectMode="ResponseRewrite" defaultRedirect="~/500.aspx">
      <error statusCode="404" redirect="~/404.aspx" />
      <error statusCode="500" redirect="~/500.aspx" />
    </customErrors>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" />
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" />
    </modules>
    <httpErrors errorMode="DetailedLocalOnly">
      <remove statusCode="404" />
      <error statusCode="404" path="404.html" responseMode="File" />
      <remove statusCode="500" />
      <error statusCode="500" path="500.html" responseMode="File" />
    </httpErrors>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <staticContent>
      <remove fileExtension=".svg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    </staticContent>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

ArticleModel.edmx

Diagram of Personal Blog Framework


ConnectionStrings.config

<connectionStrings>
  <add name="DefaultConnection" connectionString="Server=tcp:AZUREDB.database.windows.net,1433;Database=AZUREUSER_db;User ID=AZUREUSER@AZUREDB;Password=PASSWORD;Trusted_Connection=False;Encrypt=True;Connection Timeout=30" providerName="System.Data.SqlClient" />
</connectionStrings>

Resources

Tutorial Used as Guide

Project's Github Link

Community
  • 1
  • 1
Joseph Casey
  • 1,283
  • 1
  • 14
  • 34

2 Answers2

2

Posting as a community wiki, since this is not an answer, per se. However, it's important information for you to know. The ASP.NET article you're referencing is out-dated. Originally, Entity Framework only offered the Model-First and Database-First approaches, both utilizing EDMX. Entity Framework 4.1 introduced Code-First as a third approach, which uses class-based configuration and eschews EDMX. It was intended as a replacement for both Model-First and Database-First, with those two previous approaches left for compatibility only. However, the Code-First name confused many, leading to the belief that it was only an alternative to Model-First and Database-First was still needed to work with an existing database. That's is incorrect; Code-First, despite its name can work with new or existing databases. Now, the next version of Entity Framework will remove support entirely for Model-First and Database-First, leaving only Code-First.

Any new application you build should be Code-First, or you're just shooting yourself in the foot. If you have an existing database you need to work with, you can use the EF Power Tools extension to reverse engineer Code-First POCOs. I also have a more detailed guide on using Code-First with an existing database here.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • There are so many how-to's and similar tutorials on MVC out there that fall into this same category - they may *look* current, but they're not. I had to become very discerning very quickly which version of MVC/EF/Workflow any given tutorial was using, or else I could go down a dark and treacherous road very easily. – David W May 04 '15 at 15:38
  • 1
    Well EDMX is very much a *dark and treacherous road*. I'm honestly surprise EF ever got any traction in the first place initially only offering that path. I started working with MVC right after EF 4.1 landed, so I never experience those dark times. However, I've had to work with EDMX created by other developers, and my first step is always to switch it out with Code-First. EDMX is so damn finicky and next to impossible to work with without wasting countless hours to just trying to get everything to play right after every little change. – Chris Pratt May 04 '15 at 15:45
  • 1
    Thanks for this. PHP and ASP.Net have a ton of information out there, and it is hard to discern what is useful and what is not. – Joseph Casey May 04 '15 at 15:45
0

When adding the data model to your project it should have made modification to your web.config which you may have lost. It adds another connection string which in your case should look like this:

<add name="Entities" 
     connectionString="metadata=res://*/Models.ArticleModel.csdl|res://*/Models.ArticleModel.ssdl|res://*/Models.ArticleModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=Server=tcp:AZUREDB.database.windows.net,1433;Database=AZUREUSER_db;User ID=AZUREUSER@AZUREDB;Password=PASSWORD;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;&quot;" 
     providerName="System.Data.EntityClient" />
Konstantin Dinev
  • 34,219
  • 14
  • 75
  • 100