![](/img/trans.png)
[英]How to connect an already existing .Net Core application to Azure SQL Database with managed identity
[英]How to connect to existing database? .NET Core API & SQL Server 2012
美好的一天!
我正在努力將現有數據庫與現有數據連接到我的API項目。 還有如何知道我是否已經連接? 我正在使用.NET Core 1.1,而我的數據庫是SQL Server 2012。
appsettings.json:
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"ConnectionStrings": {
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=;User Id=sa;Password=Passw0rd;MultipleActiveResultSets=True"
}
}
}
Startup.cs-ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddDbContext<DefaultConnection>(
options => options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
}
我正在關注本教程,但看來這會創建新的數據庫。 http://www.mithunvp.com/aspnet-core-web-api-entity-framework-core/
非常感謝您的所有評論/解決方案/建議。
非常感謝你!
您需要在該行中添加數據庫名稱:
"DefaultConnection": "Server=COGSOL-LAP13;Database=DATABASENAME;UserId=sa;Password=Passw0rd;MultipleActiveResultSets=True"
正如CodeCaster的評論所說,您也應該使用服務器的名稱
用戶和ID之間也應有一個空格User Id
應該為
用戶身份
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.