【发布时间】:2018-11-20 07:53:32
【问题描述】:
我正在尝试构建一个解决方案架构,在该架构中我引用了一个 .net 项目,该项目包含我需要的实体框架 ORM 所需的所有代码,该实体框架 ORM 使用 Npgsql 提供程序连接到 postgres 数据库。
引用此类项目并进行查询在控制台应用程序中有效,但在 azure 函数项目中无效。
Here is a link to a solution 包含重现此错误所需的一切。在ConsoleApp1 中,使用了对eftest 的引用,并且将运行完成而不会出错。
名为FunctionApp3 的项目是失败案例。一个全新的面向.net framework 4.71的azure函数项目,引用eftest项目并查询它。如果你尝试这个项目,you will get this error。
当然,当您实际安装它如此渴望的Npgsql 4.0.2 软件包时,它会是changes to this error.
我认为这是绑定重定向的问题。所以我添加了一个类似于控制台应用程序中现有的 app.config。结果是azure functions cant use app.config files,所以我不能在连接字符串中设置绑定重定向或providerName 属性。据我所知,keyword port not supported 是由于未在连接字符串中设置 providerName 造成的。
Here is a log of the full rebuild of the azure function project.
问题:如何让这个实体框架项目与 azure 函数项目一起使用?
【问题讨论】:
-
我对 Azure 应用一无所知,但我想知道在 FunctionApp3 项目中如何处理您的 EF 特定应用设置。我的意思是来自 ConsoleApp1
app.config的以下部分:configSections、entityFramework/providers、connectionStrings/.../providerName。以我有限的理解,FunctionApp3 项目似乎不知道这些事情 -
关于如何在没有 app.config 的情况下设置 providername,this example 看起来您可以使用比当前更具体的结构编写 local.settings.json 连接字符串。
-
你看过这个帖子吗:stackoverflow.com/questions/45217166/…?
-
不,我还没有看过那个项目。谢谢,明天早上我会读一读。
标签: .net entity-framework azure-functions npgsql