c# - 将 ASP.NET Core 应用程序连接到 Google Cloud SQL

标签 c# asp.net google-app-engine google-cloud-sql

我使用 Asp.NET Core 创建了简单的应用程序。它使用 Entity Framework 和本地数据库。我将我的应用程序部署到 Google Cloud App Engine,但老实说我不知道​​如何处理我的数据库。现在我正在使用本地 sql 服务器
我的 appSettings.json 看起来像这样:

{
  "connectionStrings": {
    "smogInfoDBConnectionString": "Server=(localdb)\\mssqllocaldb;Database=SmogInfoDB;Trusted_Connection=True",
    "hangfireConnectionString": "Server=(LocalDB)\\MSSQLLocalDB;Integrated Security=true"
  }
}

当我在我的电脑上调试和使用应用程序时,它工作得很好。我知道我需要创建一个 SQL 实例,但是如何将我的应用程序连接到该数据库服务器?如何制作连接字符串?

最佳答案

您与 Google Cloud SQL 的连接字符串应如下所示:

Server=xxx.xxx.xxx.xxx;Database=DB_NAME;Uid=USER_NAME;Password=PASSWORD

关于c# - 将 ASP.NET Core 应用程序连接到 Google Cloud SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51069034/

相关文章:

c# - 如何验证 RadioButtonList 是否在 C# 中检查/选择它?

c# - 如何以编程方式启用/禁用 Azure Function

c# - 类中声明的变量的内存分配

ASP.NET 临时文件清理

python - 在Google App Engine邮件API中设置背景图像

eclipse - 请配置一个GWT SDK?

c# - foreach 循环如何解释 yield return ?

c# - 如何在asp.net mvc4中发送电子邮件

c# - ASP.NET MVC OWIN 和 SignalR - 两个 Startup.cs 文件

java - 访问 AppEngine 应用程序 ID