2017-07-24 58 views
0

我試圖使用實體框架Azure的功能裏面沒有找到。我在本地創建了我的模型並創建了它的一個DLL - 我嘗試在Console項目中使用它,並且它沒有問題。getter方法在Azure的功能

我想做同樣的在Azure的功能,所以我上傳了我的DLL函數的bin文件夾,並添加代碼的參考:

#r ".\bin\IoTDataModel.dll" 

我還增加的EntityFramework到functon本身refereced它:

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()'

「設備」 是我在的EntityFramework的車型之一。 一般我無法訪問我的任何車型,錯誤總是拋出。這裏可能是什麼問題?

+0

您是否嘗試過重新啓動功能的應用程序?這可能與此有關。 – DavidG

+0

你的project.json是否有必要的依賴關係?另外,也請你在你的項目中擁有的版本和Azure的功能 – Hammad

+0

@DavidG我重新啓動整體功能和這個錯誤不再出現。現在又有一個,但我認爲這與這個問題無關,所以我會發佈一個新帖子。如果你用相同的建議回答,我會將其標記爲解決方案。謝謝。 – Loreno

回答

2

related GitHub issue

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.

所以重新啓動功能應該現在做的工作,但你可能應該看看你的版本控制組件,以防止這種情況再次發生。

+0

謝謝,這有幫助。 – Loreno