I have a website project (C#/ASP.NET) opened in Visual Studio 11 (beta) which works with the built-in SQL Server Compact Edition. But, I would rather use my SQL Server 2012 which is installed on this machine, and I have my tables already created in it.
Question is, how do connect to it from VS11? Do I add it in the App_Data folder where I have the Compact database?
Right now I am opening my pre-made database with the
var db = Database.Open("StarterSite");
command.
If you already have the database created on SQL Server 2012, then just use it!
No need to add it to your project (and most definitely don’t copy it into
App_Data!).Just create a connection string in your
web.configsomething like:and then use that in your app using all the normal ADO.NET components like
SqlConnectionorSqlCommand:Or use something like Entity Framework to make your life even easier!