播种时EF5会中断

时间:2012-09-28 22:40:13

标签: asp.net-mvc-3 entity-framework seeding

我将MVC项目升级到EF4.3.1中的最新EF5。从那时起,我的数据库总是无法初始化。如果我将引用更改回EF4.3.1,一切正常。什么给了?

public class ArticleInitializer : DropCreateDatabaseAlways<ArticleContext>
{
    protected override void Seed(ArticleContext context)
    {
        Config.Articles.ForEach(article => context.Articles.Add(article));
        Config.Categories.ForEach(category => context.Articles.Add(category));
        Config.CareerAreas.ForEach(careerArea => context.Articles.Add(careerArea));
        context.SaveChanges();
    }
}

0 个答案:

没有答案