For those who’re following the ASP.NET Movies tutorial from Microsoft and you get to the stage where you are supposed to look at the Movies.mdf data file, you may encounter some problems. There are quite a few, and these issues aren’t unique to the movies sample and can happen to anyone trying to create projects in this way. Here are a list of problems and solutions.
Problem: The database ‘…MVCMOVIE\MVCMOVIE\APP_DATA\MOVIES.MDF’ cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported.
Solution: [It’s likely you’re running Visual Studio Web Developer or VS2010]
- You need to install the SQL Server Data Tools and LocalDB.
- Verify the MovieDBContext connection string specified on the previous page of the tutorial.
Problem:“InvalidOperation Exception was unhandled by user code” The supplied SqlConnection does not specify an initial catalog.
Solution: [It’s likely you’re running Visual Studio Web Developer or VS2010]
- You need to install the SQL Server Data Tools and LocalDB.
- Verify the MovieDBContext connection string specified on the previous page of the tutorial. Or
- You might get away with just adding “Initial Catalog=Movies;” into the connection string.
Problem: The App_Data folder in the solution explorer didn’t contain the .mdf file
Solution:
- In the Solution Explorer, click ‘show all files’.
- Then click the refresh button.
- Then expand the App_Data folder
Problem: The App_Data folder still doesn’t show anything.
Solution:
- F5 (Debug) the solution.
- Navigate to <location>/Movies in IE- this step populates the database. You could also try using update-database in nuget package manager console.
- Go back to visual studio and refresh the App_Data folder.
– This solution applies to other projects, if your .mdf isn’t there or the tables aren’t there, just try navigating to the main DbSet controller class first. This is because the migrations to code first changes are lazily applied. You can write some code in your startup that ensures all pending migrations are added to the database before any other code is run, which is generally handy anyway. I’ll be covering this in another blog post soon.
Best ASP.NET 4.6 Hosting Recommendation
ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET MVC hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.