Getter 在 Azure 函数中找不到 EF 的方法
Getter methods of EF not found in Azure Function
我正在尝试在 Azure Function 中使用 Entity Framework。我在本地创建了我的模型并创建了它的 DLL - 我尝试在控制台项目中使用它并且它没有问题。
我想在 Azure Function 中做同样的事情,所以我将我的 DLL 上传到一个函数的 bin 文件夹并在代码中添加了一个引用:
#r ".\bin\IoTDataModel.dll"
我还向函数本身添加了 EntityFramework 并引用了它:
using System.Data.Entity;
using System.Data.Entity.SqlServer;
using System.Data.Entity.ModelConfiguration.Conventions;
我写了一些代码,它使用了我在 DLL 中的模型并且编译正常。问题出现在运行时。
示例代码:
using (var context = new IoTDataBaseContext())
{
var dev = context.Device.FirstOrDefault();
}
抛出此错误:
mscorlib: Exception has been thrown by the target of an invocation. f-EventHubMessageHandler__741454837: Method not found: 'System.Data.Entity.DbSet`1 IoTDataModel.IoTDataBaseContext.get_Device()'
"Device" 是我在 EntityFramework 中拥有的模型之一。
通常我无法访问我的任何模型,总是会抛出错误。这可能是什么问题?
if the assembly is properly versioned (i.e. the assembly identity changes as you change the types), this should work as expected and the new version will be resolved. Otherwise; you'll need to restart the function app to resolve the assembly. Deleting the function app is not required.
因此,现在重启您的功能应该可以完成工作,但您可能应该考虑对程序集进行版本控制以防止再次发生这种情况。
我正在尝试在 Azure Function 中使用 Entity Framework。我在本地创建了我的模型并创建了它的 DLL - 我尝试在控制台项目中使用它并且它没有问题。
我想在 Azure Function 中做同样的事情,所以我将我的 DLL 上传到一个函数的 bin 文件夹并在代码中添加了一个引用:
#r ".\bin\IoTDataModel.dll"
我还向函数本身添加了 EntityFramework 并引用了它:
using System.Data.Entity;
using System.Data.Entity.SqlServer;
using System.Data.Entity.ModelConfiguration.Conventions;
我写了一些代码,它使用了我在 DLL 中的模型并且编译正常。问题出现在运行时。 示例代码:
using (var context = new IoTDataBaseContext())
{
var dev = context.Device.FirstOrDefault();
}
抛出此错误:
mscorlib: Exception has been thrown by the target of an invocation. f-EventHubMessageHandler__741454837: Method not found: 'System.Data.Entity.DbSet`1 IoTDataModel.IoTDataBaseContext.get_Device()'
"Device" 是我在 EntityFramework 中拥有的模型之一。 通常我无法访问我的任何模型,总是会抛出错误。这可能是什么问题?
if the assembly is properly versioned (i.e. the assembly identity changes as you change the types), this should work as expected and the new version will be resolved. Otherwise; you'll need to restart the function app to resolve the assembly. Deleting the function app is not required.
因此,现在重启您的功能应该可以完成工作,但您可能应该考虑对程序集进行版本控制以防止再次发生这种情况。