Reputation: 70
I have copied my code across into a new project and I am failing to see any .mdf or .log files generated after running. Under Data Connections I can see and interact with the tables in the database, yet no files are created within the App_Data folder.
Here is my DB context class:
public class BareCupboardDB : DbContext
{
public DbSet<Recipe> Recipes { get; set; }
public DbSet<NutritionalValue> NutritionalValues { get; set; }
public DbSet<RecipeStep> RecipeSteps { get; set; }
public DbSet<Ingredient> Ingredients { get; set; }
public DbSet<RecipeIngredient> RecipeIngredients { get; set; }
}
My Application_Start() code:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
//System.Data.Entity.Database.SetInitializer(new BareCupboard.Models.RecipeContextInitializer());
Database.SetInitializer(new CreateDatabaseIfNotExists<BareCupboardDB>());
var context = new BareCupboardDB();
context.Database.Initialize(true);
}
And my connection string:
<add name ="testConnection"
connectionString="data source= .\SQLExpress;Integrated Security=SSPI;Initial Catalog=BareCupboardDB"
providerName="System.Data.SqlClient"/>
As far as I can see, this should absolutely generate my database files.
I appreciate any help.
Many thanks.
Upvotes: 0
Views: 4069
Reputation: 1644
Your connection string is to an SQL Server instance so you should find the tables in there. You can use SQL Management Studio to have a look
Upvotes: 2