Steps to take for connecting to SQL Server when using the ASP.NET Entity Framework to create a database
Steps to take for connecting to SQL Server when using the ASP.NET Entity Framework to create a database
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.
enable-migrations
update-database
App_data
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
Anyway you can also reach Scott directly on the discussion tab of the course.
– CodeNotFound
2 days ago
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
2 days ago
@CodeNotFound here is the initial catalog part: Initial Catalog=aspnet-eManager.Web-20180623124356;
– Vaishanavi Mirapurkar
2 days ago
@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: stackoverflow.com/questions/21563940/… 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
2 days ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Show us the intial catalog part of your connection string?
– CodeNotFound
2 days ago