Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing from local database to SQL Server hosted on a server

So I'm fairly new to MVC and C# in Visual Studio. I recently completed the tutorial located at:

http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-basic-crud-functionality-with-the-entity-framework-in-asp-net-mvc-application

It was fun and educational in some aspects. I have one question though about the database it connects to, in the tutorial it creates a local SQL Server database and the CRUD then works off that. I currently have an external SQL Server database hosted on a server that I would like to be able to play with, I have successfully connected to it through Visual Studio (2012) but was wondering how hard it is to transfer the CRUD over to it.

After reading up a little bit I altered the connection string, and added:

using System.Data.SqlClient

But I am still using:

using System.Data.Entity

Unsure if I need both, and I am ofc using EF (Entity Framework).

Can anyone advise what other steps would need to be done in order to successfully transfer this over? Or in what direction I should look because tbh I am not a database or SQL expert (or MVC) and it gets a bit confusing.

Any helps, links or tutorial locations would be greatly appreciated.

like image 930
Bohdi Avatar asked Nov 04 '22 17:11

Bohdi


2 Answers

Now that you are looking at the right place. You need to load the schema and data to it. Schema being the tables and relations that you have set up and the data being all the information you have already gathered and entered. I use Web Deploy to do this. Below on some links to help you with this. If you are in visual studio. Go to the Project Menu Package Publish settings. Then click on Package/Publish SQL. Look at the settings in there and look at the image and links below and you should get it. Let me know if this helps.

Web Publish Toolbar

Great Web Deploy Explanation

like image 79
jackncoke Avatar answered Nov 11 '22 02:11

jackncoke


I would create a .sqlproj from the LocadDB version, then publish that to your SQL Server. Change the connection string in your MVC project, and you should be good to go. Note that your data won't follow.

like image 41
Andrew Clear Avatar answered Nov 11 '22 02:11

Andrew Clear