Making EntityFramework play nice with Azure Key Vault

Make a separate class containing a constructor to pass in the connection string from KV.  Don’t modify the constructor in the Whatever.Context.cs file because it’ll get regenerated when you update the model and overwrite any changes you make in there.

Get the connection string from the “update model from database” command, but replace " with actual quotes. The connection string in KV should look like this:

metadata=res:///EntityFramework.DataWarehouse.csdl|res:///EntityFramework.DataWarehouse.ssdl|res://*/EntityFramework.DataWarehouse.msl;provider=System.Data.SqlClient;provider connection string="data;initial catalog=thedatabase;user id=dbusername;password=passwordgoeshere;MultipleActiveResultSets=True;App=EntityFramework”