In the end, Stephen Reindel pushed me in the right direction; Code Based Configuration for Entity Framework.
[DbConfigurationType(typeof(MyDBConfiguration))] public partial class MyDB { public static MyDB GetDB() { var connString = **MY CONN STRING FROM SOMEWHERE**;
With MyDbConfiguration as follows:
public class MyDBConfiguration: DbConfiguration { public MyDBConfiguration() { SetProviderServices("System.Data.SqlClient", SqlProviderServices.Instance); SetDefaultConnectionFactory(new SqlConnectionFactory()); } }
With the above code, EF never queries the configuration files associated with AppConfig. But remember , if you have EF entries in your configuration file, it will try to use them, so make sure they are gone.
In terms of azure features, this means that I used the Azure Functions configuration panel in azure to punch in my ConnectionString without metadata and provider name, and then uploaded them to GetDB.
Edit: as requested, the following explanatory text is given above: You cannot add EF connection metadata to Azure Functions, since they do not use app.config in which you can specify it. This is not part of the connection string, but represents connection metadata, except for the connection string that EF uses to map to a specific C # class and SQL provider, etc. To avoid this, you hardcode it using the example above. You do this by creating a class that inherits from DBConfiguration, and you mark (with an attribute on the partial class) your EF database class with this.
This DBConfiguration function contains another way to create a new database object in which this metadata is hard-coded, but the connection string is extracted from your application settings in Azure. In this example, I just used the static method, but I think it could be a new constructor.
Once you have this static method in the game, you can use it to get the new database in your database code, for example:
using (var db = MyDB.GetDB()) {
This allows you to use EntityFramework without APP.Config, and you can still change the connection string using the Azure APP function parameters.
Hope that helps