ProjectA包含EF代码,通常托管在MVC项目中。现在,我想将其“包装”到Azure(v1)函数(称为ProjF)中,以便公开使用计划(以便我们可以扩展繁重的调用)。
所以我推荐ProjA,很好。但是如何获得所有EF设置呢? Connectionstring通过host.settings.json通过fina,但是其余的来自web.config? (注意,我们使用PostgresSql和Devart)。由于azure函数没有app.config或web.config,因此这些设置必须在其他位置进行设置。
web.config中的相关部分:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
和
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity.EF6, Version=7.12.1328.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Devart.Data.PostgreSql" />
<add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version=7.12.1328.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>
</system.data>
看过从 How to specify EntityFramework ProviderName in an Azure Function 但由于我们使用的是Postgres + Devart,因此无法确定要使用的值
答案 0 :(得分:0)
当app.config不可用时,可以通过代码添加寄存器DbProviderFactory和EF6提供程序。示例如下:https://forums.devart.com/viewtopic.php?t=28550#p97525。