【发布时间】:2018-05-28 02:42:14
【问题描述】:
我在使用 .net 核心的 Azure Functions 中使用 EF 核心 2.0。我正在尝试从定义的 local.settings.json 读取 db ConnectionString:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
},
"ConnectionStrings": {
"MyDbConnStr": "Data Source=.;Initial Catalog=xxxxxxx"
}
}
Environment.GetEnvironmentVariable() 不返回任何连接字符串信息,我也不能将 ConfigurationManager.ConnectionStrings 与 .net 核心一起使用。 如何从代码中访问连接字符串?
【问题讨论】:
-
如何在本地加载带有 azure 函数的 EFCore 2.X?我试过了,它无法加载 EFCore。你在用视觉工作室吗?
-
@DOMZE 是的,使用 VS 2017,版本 15.5.2 和 .net core 2 Functions 模板
netstandard2.0 v2 PropertyGroup> -
@DOMZE 确保您引用了 Sdk.Functions 1.0.6 和 2.0.0 EF。当前存在 Azure Functions .NET Core 错误
-
你我的朋友是救世主!非常感谢。
标签: c# azure entity-framework-core azure-functions ef-core-2.0