Have put my MVC4/EF5 app on a different machine and now want to generate the database. Have code-first approach and have a seed method in my configuration file although I've lost the code file that generated the database commands in c#. Original solution was VS 2010 but have opened ok in VS 2012 and built and run the home page. As soon as I go to a database-dependent page then I get error.
A network-related or instance-specific error occurred while establishing a connection to SQL Server.
The server was not found or was not accessible.
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I have LocalDB 11.0 and 2012 Express installed.
How can I 'reset' so that I can re-create my database on my new machine with my existing code?
I'd put in more code/details but unfortunately not sure which bits are relevant to solving the problem.
UPDATE 1 To get a SQL Express database created I've tried changing the connection string to
<add name="RecruitModelContext" providerName="System.Data.SqlClient"
connectionString="Server=.\SQLEXPRESS;Initial Catalog=Recruitment;
Integrated Security=True;"/>
Also, I'm calling the following from the Application_Start() in global.asax
using (var db = new RecruitModelContext())
{
db.Database.Initialize(true);
}
But now I'm getting ProviderManifestToken errors as per other posts. I've tried everything I could find there but not getting a resolution.
UPDATE 2 My connection string was incorrect on the Server name (used fully qualified servername\instancename - had setup different instance name to the default) so it was never seeing my SQL instance.
<add name="RecruitModelContext"
providerName="System.Data.SqlClient"
connectionString="Server=MIKEPOOLE72\SQL2012EXPRESS;Initial Catalog=Recruitment;Integrated Security=True;"/>
Removed the initialize code above. Re-ran enable-migrations -Force from the Package Manager Console. Then replaced the Configuration file generated with the one with my Seed method in. Then ran Update-Database from the console and it created my DB with my data.
Thanks to @Code Chops for setting me on my way.
Note I used these MSDN links also which helped on the basics and I'm sure I'll be revisiting these again. http://msdn.microsoft.com/en-US/data/jj556606 http://msdn.microsoft.com/en-us/data/jj592674