3、执行代码
public class Destination { public int DestinationId { get; set; } public string Name { get; set; } public string Country { get; set; } public string Description { get; set; } public string Description12345 { get; set; } public byte[] Photo { get; set; } public List<Lodging> Lodgings { get; set; } } public class Lodging { public int LodgingId { get; set; } public string Name { get; set; } public string Owner { get; set; } public bool IsResort { get; set; } public bool IsResort1 { get; set; } public bool IsResort2 { get; set; } public Destination Destination { get; set; } } public class BreakAwayContext : DbContext { public BreakAwayContext() : base("MyContext") { } public DbSet<Destination> Destinations { get; set; } public DbSet<Lodging> Lodgings { get; set; } } static void Main(string[] args) { var d = DateTime.Now.Date.ToString("yyyyMM"); var destination = new Destination { Country = "Indonesia", Description = "EcoTourism at its best in exquisite Bali", Name = "Bali" }; using (var context = new BreakAwayContext()) { context.Destinations.Add(destination); context.SaveChanges(); } Console.WriteLine("OK"); }
4、用Nuget程序包管理器控制台更新数据库
Enable-Migrations
Update-Database
5、运行
EntityFramework Code First Demo 更新数据库
标签:控制 support hot span 程序包 get token des 数据