简体   繁体   English

在 ASP.NET MVC 中将 SQL 服务器连接到 Azure 数据库

[英]Connecting SQL Server to Azure Database in ASP.NET MVC

I have been developing applications using ASP.NET MVC but using the IIS localhost for testing.我一直在使用 ASP.NET MVC 开发应用程序,但使用 IIS localhost 进行测试。 I want to deploy for production now but a bit stuck.我现在想部署生产,但有点卡住了。

I have subscribed for the Azure free subscription.我已订阅 Azure 免费订阅。 I have been able to deploy the application to azure and it is live on "mydomain".azurewebsites.net.我已经能够将应用程序部署到 azure 并且它位于“mydomain”.azurewebsites.net 上。 The issue I am having now is the database.我现在遇到的问题是数据库。

I want to connect a database to it.我想将数据库连接到它。 I used EF Code-First approach throughout the project.我在整个项目中使用了 EF Code-First 方法。 My questions are below:我的问题如下:

  1. What will be the content of my Web.config as regards connection string before deploying the application.在部署应用程序之前,我的Web.config关于连接字符串的内容是什么。
  2. How do I create a database and connect it successfully to my application on Azure如何创建数据库并将其成功连接到 Azure 上的应用程序

You can read this article, then you will know what code-first does at runtime.你可以阅读这篇文章,然后你就会知道代码优先在运行时做了什么。

Database Initialization in Entity Framework 6 Entity Framework 6 中的数据库初始化

在此处输入图像描述

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM