gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:38:28 25 4
gpt4 key购买 nike

我有一个使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com