DFord
DFord

Reputation: 2358

Code First Entity Framework not building database

I am trying to implement Entity Framework using code first but it is not building the database tables. I'm not sure what i'm doing wrong. I am using this tutorial -http://msdn.microsoft.com/en-us/data/jj193542 but I am trying to use it with a web application instead of a console application. I created a Models folder and put my context class in that folder. Here is my dbcontext code:

namespace GroceryAssistant.Model
{
    public class GroceryShopperContext : DbContext
    {
        public DbSet<List> Lists { get; set; }
        public DbSet<ListItem> ListItems { get; set; }
        public DbSet<User> User { get; set; }
    }
}

I created put the connection string in the web.release.config and the web.debug.config files. I'm not sure what else I have to do. Where should i put my DbContext code so that the tables will be created?

Upvotes: 1

Views: 108

Answers (1)

Z .
Z .

Reputation: 12837

If you do not change the default behavior, the first time you use the DbContext it will create your database.

Upvotes: 1

Related Questions