0

I am following the ASP.NET MVC4 tutorial by Scott Allen on Pluralsight, and I am trying to create an internet ASP.NET MVC web application using Entity Framework.

In the tutorial, Allen uses enable-migrations, and then the command update-database to create a database based on C# code. That command creates a database in the App_data folder of the solution. There is no database created beforehand. The command creates a database using the SQL statements from the migration.

I am trying the same procedure, but it seems like there is something wrong with Visual Studio 2015's connection to LocalDB. I have scoured web for an solution to this problem for two days now, and here I am.

What steps do I take to connect LocalDB to Visual Studio 2015 in order to run that command successfully?

The image shows the error I am getting:

Error finding LocalDB

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Show us the intial catalog part of your connection string? – CodeNotFound Jun 28 '18 at 21:10
  • Anyway you can also reach Scott directly on the [discussion](https://app.pluralsight.com/library/courses/mvc4-building/discussion) tab of the course. – CodeNotFound Jun 28 '18 at 21:12
  • You have 2 connection strings and it looks like the 2nd one is the one that you want to use, but the first connection string is the one referring to localdb. Did you try switching them? – IQtheMC Jun 28 '18 at 22:19
  • @CodeNotFound here is the initial catalog part: Initial Catalog=aspnet-eManager.Web-20180623124356; – Vaishanavi Mirapurkar Jun 28 '18 at 23:45
  • @IQtheMC I tried switching them the way you suggested.No difference. I am running the instance of LocalDB as per the first suggestion in this post: https://stackoverflow.com/questions/21563940/how-to-connect-to-localdb-in-visual-studio-server-explorer# But this is not exactly what I need, because I want the database to be created by the entity framework. Is that way of running the localDB correct? – Vaishanavi Mirapurkar Jun 29 '18 at 00:02
  • You might need to get rid of the slash after |DataDirectory| https://stackoverflow.com/questions/13236483/make-ef-use-local-database-in-app-data-folder – IQtheMC Jun 29 '18 at 19:12

0 Answers0