In previous posts I used EF using the local database and using the Azure SQL Server. This is the configuration I use now to connect to my local database in Debug mode and to my Windows Azure database in Release Mode.
App.config
<connectionStrings> <!--Azure MyFood database--> <add name="MyFoodAzure" providerName="System.Data.SqlClient" connectionString="Data Source=i608rt1tak.database.windows.net;Initial Catalog=MyFood;Integrated Security=False;User ID=ravened;Password=pass¿;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False" /> <!--Local MyFood database--> <add name="MyFoodLocal" providerName="System.Data.SqlClient" connectionString="Server=(localdb)\v11.0;Integrated Security=true;Database=MyFood;"/> </connectionStrings>
DbContext
public class FoodContext : DbContext { // NOTE: Call base constructor to specify the connection string name #if !DEBUG // In Release mode it will look for the Cloud connection string public FoodContext() : base("name=MyFoodAzure") { } #else // In Release mode it will look for the Cloud connection string public FoodContext() : base("name=MyFoodLocal") { } #endif public DbSet<Food> Foods { get; set; } public DbSet<Recipe> Recipes { get; set; } public DbSet<FridgeEntry> Fridge { get; set; } }