How to specify EntityFramework ProviderName in an Azure Function

前端 未结 6 645
梦毁少年i
梦毁少年i 2020-12-31 15:32

I\'m trying to port some webjob code to the new Azure Functions. So far I\'ve managed to import my DLL\'s and reference them succesfully, but when I use the connection strin

6条回答
  •  無奈伤痛
    2020-12-31 15:59

    Stumbled upon this and solved it like this, inside of the Azure Function.

    public static class MyFunction
    {
         // Putting this in more than one place in your project will cause an exception,
         // if doing it after the DbConfiguration has been loaded.
         static MyFunction() =>
             DbConfiguration.Loaded += (_, d) =>
                 d.AddDefaultResolver(new global::MySql.Data.Entity.MySqlDependencyResolver());
    
    
        // The rest of your function...
        //[FunctionName("MyFunction")]
        //public static async Task Run() {}
    }
    

提交回复
热议问题