2

Im pretty new to MVC so I tried myself at this tutorial which seemed a good idea: http://www.asp.net/mvc/overview/getting-started/introduction/getting-started

Everything went really well until the point when I got to chapter 5 to create a Model. I created the model in "almost" the same way as the tutorial says (Didnt have the same application context in the dropdown, so I took the one that was presented) and that did work. But when I try to start up the application now I get the following error:

A network-related or instance- specific error occurred while establishing a connection to SQL Server . The server was not found or it can not be accessed. Verify that the instance name is correct and that SQL Server allows remote connections. (provider : SQL Network Interfaces , error : 56 - \ " SQLUserInstance.dll \ " can not be loaded from the location specified in the registry Verify that the function Local Database Runtime SQL Server Express is installed correctly. .    

The Inner exception would be: % 1 is not a valid Win32 application

Hope someone can help me with this, since I have no clue what Ive done wrong.

VIP
  • 89
  • 2
  • 9
  • Did you check to make sure that you have the LocalDB functionality installed? – svanelten Dec 10 '14 at 13:03
  • Did you use a database or not? – clement Dec 10 '14 at 13:09
  • @svanelten how do I check that? – VIP Dec 10 '14 at 13:14
  • There is a registry key for that: http://stackoverflow.com/questions/11628316/sql2012-localdb-how-to-check-in-c-sharp-if-it-is-currently-installed – svanelten Dec 10 '14 at 13:32
  • @clement the tutorial says that the database will be created with LocalDB which is installed together Visual Studio. – VIP Dec 10 '14 at 13:35
  • @VIP - Did you get the chance to look into my answer? Still you are facing the issue? – Rahul Singh Dec 10 '14 at 16:20
  • 1
    @RahulSingh yeah seems that was the problem I was facing after I found I had to reinstall my VS since there seemed to be some other problem that the LocalDB could not be found. – VIP Dec 11 '14 at 11:47

1 Answers1

0

That's probably because you have not disconnected the connection, Try this:-

Open Server Explorer -> DBContext (Probably MovieDBContext in your case) , right click on that and select Close Connection.

Also, you need to set the right connection string name for the entity framework database context. Check in Web.Config file, your ConnectionStrings key name should exactly match with your DBContext (MoviesDBContext here).

Also, I noticed you said, you couldn't find the right DBContext in dropdown that's because you might not have build your solution before doing that.

Rahul Singh
  • 21,585
  • 6
  • 41
  • 56