Question

I am going through this tutorial and I'm stuck on step 5 - Creating a Connection String and Working with SQL Server LocalDB. The error I get is:

There was an error running the selected code generator:

'Unable to retrieve metadata for 'MvcMovie.Models.Movie'. Unable to find the requested .Net Framework Data Provider. It may not be installed.'

I have searched the internet for an answer for days. I have tried many solutions, but none have worked. I have checked and re-checked the code, I have Visual Studio Express 2013 for Web with update 1 on a Windows 7 64-bit PC. Can anyone help me figure this out using LocalDB and not another DB product?

Here is the 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=301880
  -->
<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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MvcMovie-20140207025827.mdf;Initial Catalog=aspnet-MvcMovie-20140207025827;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    <add name="MovieDBContext"
      connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movie.mdf;Initial Catalog=Movies;Integrated Security=True"
      providerName="System.Data.SqlClient"
    />

  </connectionStrings>
  <appSettings>
    <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" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthenticationModule" />
    </modules>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <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.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.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="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

I have already answered some questions on the ASP.NET forum and posted screenshots so please read this over - Here

Was it helpful?

Solution 2

Sorry, it was an issue with one computer. I was able to do the same thing on another computer.

OTHER TIPS

Please modify the Connection String as shown below:

<add name="MovieDbContext" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />

You can check the following article for further reference:

http://www.c-sharpcorner.com/UploadFile/4b0136/working-with-model-class-and-connection-string-in-mvc-5/

Please check the Event Viewer details for your application. If the LocalDb is corrupted then run the following commands:

SqlLocalDB Create C
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top