c# - Azure函数无法在没有实体提供程序的情况下使用连接字符串

标签 c# entity-framework azure azure-functions

我有一个使用 DAL dll 的 Azure Function 系统。该 dll 使用 Entity Framework 连接到 SQL 数据库,并且对于我们的数据库优先代码采用 UnitOfWork 格式。

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

enter image description here

我已经从 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."

因此,通常提供程序名称是 Entity Framework ,但我不知道如何将其包含在代码中。我的问题是,如何连接此连接字符串并拥有 Entity Framework 提供程序?

最佳答案

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

关于c# - Azure函数无法在没有实体提供程序的情况下使用连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40043482/

相关文章:

c# - ASP 菜单控件未对齐

azure - 在 Visual Studio 中运行时无法访问 KeyVault

entity-framework - 首先使用抽象类进行代码,无法生成 fk

c# - 简单的 DbSet<TEntity>.Find() 调用永远占用

c# - 自引用实体和插入顺序 - 使用 Entity Framework Code First

reactjs - 使用 React 在 Azure Blob 存储中上传文件

c# - Chrome 在从 ASP.NET Web Api 流式传输 FFMPEG 输出时超时

c# - 无法为该文件显示设计器,因为无法设计其中的任何类。视觉 C#

c# - 如何在数字前添加货币符号?

c# - 如何将 ICommand 添加到 FrameworkElement 中的事件?