asp.net – 如何使用EntityFramework种子数据代码第一次迁移

嗨,我使用这个nuGet软件包的Beta 1版本,数据库已经被创建,我需要知道是否有一种通过迁移填充我的表的方式。 Thanxs

解决方法

介绍文章显示如何种子数据
http://blogs.msdn.com/b/adonet/archive/2011/11/29/code-first-migrations-beta-1-no-magic-walkthrough.aspx

Seed data:
Override the Seed method in this class to add seed data.
– The Seed method will be called after migrating to the latest version.
– You can use the DbContext.AddOrUpdate() helper extension method to avoid creating
duplicate seed data. E.g.

myContext.AddOrUpdate(c => c.FullName,new Customer { FullName = "Andrew Peters",CustomerNumber = 123 },);

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...