5

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.

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

This link is way better learn.iis.net/page.aspx/1081/…
1

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.

Comments

0

I worked with webforms but i believe it is the same you will need to edit the Connection string in the web.config file in your solution to point at the hosted DB in order to play with it.

SQL Server:

Data Source={SERVER NAME};Initial Catalog={DataBaseName};User Id={SQLUsername};Password={SQLPassword};

MySQL:

Server={SERVER NAME};Database={DataBaseName};Uid={SQLUsername};Pwd={SQLPassword};

Let me know if this helps.

1 Comment

<add name="DBTest" connectionString="Data Source=**.***.***.***;Initial Catalog=DBTest;Persist Security Info=True;User ID=*********;Password=***********" providerName="System.Data.SqlClient" /> --- Already changed my connection string to this. is that all i need to do?
0

Authentication: SQL Server Authentication

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.