[英]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. 我试图先使用代码实现Entity Framework,但它没有构建数据库表。 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.
我正在使用本教程-http: //msdn.microsoft.com/zh-cn/data/jj193542,但我尝试将其用于Web应用程序而不是控制台应用程序。 I created a Models folder and put my context class in that folder.
我创建了一个Models文件夹,并将上下文类放在该文件夹中。 Here is my dbcontext code:
这是我的dbcontext代码:
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. 我创建了将连接字符串放入web.release.config和web.debug.config文件中。 I'm not sure what else I have to do.
我不确定我还需要做什么。 Where should i put my DbContext code so that the tables will be created?
我应该在哪里放置DbContext代码,以便创建表?
如果不更改默认行为,则首次使用DbContext时,它将创建数据库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.