[英]Connect Azure database to existing Asp.Net web application
I'm actually working on an university project and have to figure out how to connect my windows azure database to an already existing ASP.net web application project. 我实际上正在从事一个大学项目,并且必须弄清楚如何将Windows Azure数据库连接到已经存在的ASP.net Web应用程序项目。
The web application should run on smartphones and tablets. 该网络应用程序应在智能手机和平板电脑上运行。 Since this is a group project, we use TFVC to manage the project. 由于这是一个小组项目,因此我们使用TFVC来管理项目。
Our client supplied an mysql script that will create the tables needed. 我们的客户提供了一个mysql脚本,它将创建所需的表。 The Database is hosted in Azure and we want to access it through Visual Studio ultimate, so we can reveice data from the DB and integrate it's data in the application. 该数据库托管在Azure中,我们希望通过Visual Studio Ultimate进行访问,因此我们可以从数据库中获取数据并将其数据集成到应用程序中。
I also got the connection string, so I could use it if needed. 我还获得了连接字符串,因此可以在需要时使用它。
So my question is: How can I connect to the database through visual studio and afterwards: how can I access to it? 所以我的问题是:如何通过Visual Studio连接到数据库,之后如何访问数据库? With access I mean, how and where can I use SQL queries in Visual Studio? 我的意思是访问,在Visual Studio中如何以及在哪里使用SQL查询?
I don't really know where to start, whether it is connecting to the DB via code or on another way. 我真的不知道从哪里开始,无论是通过代码还是以其他方式连接到数据库。
Every kind of help is welcome. 欢迎各种帮助。
Thank you in advance. 先感谢您。
Your question is still quite vague on specifics of what you want to achieve but hopefully this answers it. 您的问题对于要实现的目标仍然很模糊,但是希望可以回答。 If not, please provide even more detail on your question. 如果没有,请提供有关您问题的更多详细信息。
If you just want to see the DB in Visual Studio and interact with it 如果您只想在Visual Studio中查看数据库并与之交互
A side box will open and you can navigation through Azure then to your database. 将打开一个边箱,您可以在Azure中导航,然后导航到数据库。
Personally I prefer using SQL Server Management Studio, its much more responsive that the UI through Visual Studio. 我个人更喜欢使用SQL Server Management Studio,它比通过Visual Studio的UI响应更快。
If you want to connect your application to Azure, as in code an application that talks to a database, then you just need to replace the connection string in your Web.Config to your Azure Connection String. 如果要将应用程序连接到Azure(如与数据库通信的应用程序的代码所示),则只需将Web.Config中的连接字符串替换为Azure连接字符串。 Then either use ADO.NET, Entity Framework or another ORM. 然后使用ADO.NET,实体框架或其他ORM。
I recommend Entity Framework but it all depends on what your circumstances and project requirements are. 我建议使用Entity Framework,但这取决于您的情况和项目要求。
If the DB already has its schema defined get started here: https://www.asp.net/mvc/overview/getting-started/database-first-development/setting-up-database 如果数据库已经定义了其架构,请从这里开始: https : //www.asp.net/mvc/overview/getting-started/database-first-development/setting-up-database
If its empty you can use code first: http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application 如果为空,则可以先使用代码: http : //www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model -用于-AN-ASP净MVC应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.