Asked by:
Deploying MVC 5 Database on IIS Manager in Windows 7

Question
-
User-1264304776 posted
Hi, I am a developer of Asp.Net MVC 5 but I am in surprised how hard it is to deploy my site in local network and not in azure.
Anyways this is about my database, I have a hard time on knowing how should I go with the database because I use Entity Framework and LocalDb
but
I read somewhere that it is not advisable to use LocalDb, so if not LocalDb what should I use that my application will still work?
And what applications do I need to install? Should I install MS Express or something?
Please help I am stuck for a day or two in this stepTuesday, September 29, 2015 3:48 AM
All replies
-
User-821857111 posted
If you are only running the application for local use (on a PC instead of a proper server), you can use LocalDb.
Tuesday, September 29, 2015 4:21 AM -
User-1264304776 posted
I plan to deploy it on local network :) is that the same thing in your mind? Anyways if I am going to use LocalDb what steps should I take and softwares to install? THANKS
Tuesday, September 29, 2015 4:37 AM -
User-821857111 posted
See this: http://stackoverflow.com/questions/23320013/how-to-install-localdb-separately
Tuesday, September 29, 2015 5:42 AM -
User1751268424 posted
Hi,
Changing where database is located is not a big issue. You only need to change your connectionString point to where is your database is located.
Here samples for your references:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication3-20150929043946.mdf;Initial Catalog=aspnet-WebApplication3-20150929043946;Integrated Security=True" providerName="System.Data.SqlClient" /> <add connectionString="Server=192.168.151.2;Database=dTrack;User ID=xxxx;Password=*******" name="DefaultConnection" providerName="System.Data.SqlClient" /> <add name="AllimahDbContext" connectionString="metadata=res://*/AllimahModel.csdl|res://*/AllimahModel.ssdl|res://*/AllimahModel.msl;provider=System.Data.SqlClient;provider connection string="data source=192.168.151.2;initial catalog=databaseName;user id=userId;password=****;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
You can post your connectionString to give you an example base on your connection.
Change the location of your database, you can copy your database into database server folder, then attached to your database server.
If you use your current windows 7 as a database server, you need to install database first.
Hope can help and have fun.
Tuesday, September 29, 2015 5:45 AM -
User-1264304776 posted
Ok I installed LocalDb Express from Web Platform Installer, I did not change the connection string since I insert my mdf on the same folder which is app_data then this pops up
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: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist.
Tuesday, September 29, 2015 6:27 AM -
User1751268424 posted
Please post your connectionString.
This is my test connectionString:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication3-20150929043946.mdf;Initial Catalog=aspnet-WebApplication3-20150929043946;Integrated Security=True" providerName="System.Data.SqlClient" />
Tuesday, September 29, 2015 6:31 AM -
User-1264304776 posted
Please post your connectionString
Here: <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-FJBJAB-Internal-20150914093726.mdf;Initial Catalog=aspnet-FJBJAB-Internal-20150914093726;Integrated Security=True" providerName="System.Data.SqlClient" />
Tuesday, September 29, 2015 6:33 AM -
User1751268424 posted
Hi,
It seems you do not have a proper LocalDb. I have tried my connectionString without any problem. And I can not find any error on your connectionString.
Tuesday, September 29, 2015 6:46 AM -
User-1264304776 posted
How Can I test that, I just installed LocalDb Express. I also installed sql express for good measure but no change :(
Tuesday, September 29, 2015 7:17 AM -
User-166373564 posted
Hi,
How Can I test that, I just installed LocalDb Express. I also installed sql express for good measure but no change :(
Please follow this guide to create your connection String and working with SQL Server LocalDB, see: Creating a Connection String and Working with SQL Server LocalDB
LocalDB Connection String Example:
<add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFileName=|DataDirectory|\DatabaseFileName.mdf;InitialCatalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True" />
Hope it helps.
With regards,
Angie
Thursday, October 1, 2015 10:56 PM