0

I just started with asp.net mvc, I used the scaffolding generator to create a controller.

My model is called: Person, I set up the DbContext class correctly. It did generate all the views and the controller actions but it throws an exception and points me to:

    // GET: /Person/

    public ActionResult Index() {
        return View(db.Persons.ToList()); //this line is highlighted as error
    }

I browsed a few questions on SO and google and it basically says that I have to setup a localDB in order to get rid of that error.

If the resources are right, the localDb should be located at the App_Data folder right? Mine is empty ...

Isn't Visual Studio 2012 supposted to set that up for me ?

This is the error message:

provider: SQL Network Interfaces, error: 26

Should I create the localDb file manually?

Any suggestions?

edit:

This is my connectionString (Web.config)

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-PersonDb-20160108102518;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-PersonDb-20160108102518.mdf" providerName="System.Data.SqlClient" />
  </connectionStrings>
AME
  • 2,262
  • 6
  • 19
  • 39

0 Answers0