【问题标题】:Azure Function unable to use connection string with no Entity providerAzure 函数无法使用没有实体提供程序的连接字符串
【发布时间】:2016-10-14 12:43:52
【问题描述】:

我有一个使用 DAL dll 的 Azure Function 系统。此 dll 使用实体框架连接到 SQL 数据库,并且是我们的数据库优先代码的 UnitOfWork 格式。

在 azure 函数中,没有标准的“app.config”文件可以用我的数据库连接字符串进行更新。所以我在应用程序设置的 GUI 中添加了它:

我已经从 app.config 复制了代码,只需从配置中获取值,转换 " 值,然后将其粘贴到 GUI 中。

 <add name="Entities" connectionString="<This is what I copied>" providerName="System.Data.EntityClient" />

但是,每当我运行代码时,我都会收到此错误:

2016-10-14T12:39:44.248 C# ServiceBus queue trigger function processed message: test
2016-10-14T12:39:44.265 Getting UnitOfWork
2016-10-14T12:39:44.607 Getting Repository
2016-10-14T12:39:44.639 ERROR The connection string 'Entities' in the application's configuration file does not contain the required providerName attribute."

因此,通常提供者名称是实体框架,但我不知道如何将其包含在代码中。我的问题是,我如何连接这个连接字符串,并有一个实体框架提供者?

【问题讨论】:

  • 您是否设法在没有基于代码的配置的情况下使其正常工作?

标签: c# entity-framework azure azure-functions


【解决方案1】:

如果您使用的是 Entity Framework 6 或更高版本,您是否尝试过使用Code-based configuration?可以在这里找到一些示例实现,

【讨论】:

  • 如何使用带有 edmx 文件的 DB 模型来做到这一点?
  • @batmaci,这适用于您的场景吗? stackoverflow.com/questions/34355909/…
  • 我也有同样的问题,我首先设置了数据库。我不认为需要从这里切换以使其工作,但解释在 Azure Functions 上使用连接字符串的精确方式的指南非常薄!
猜你喜欢
  • 2012-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-07
  • 2021-04-20
相关资源
最近更新 更多