标签:style blog io color ar sp 数据 div on
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleAppEF { class Program { static void Main(string[] args) { testEntities context = new testEntities(); //添加实体 //t_user t = new t_user(); //t.username = "test"; //t.times = DateTime.Now; ////添加user数据 //context.Entry(t).State = System.Data.EntityState.Added; //删除实体 //t_user user = new t_user(); //user.id = 6; //数据entity数据 //context.Entry(user).State = System.Data.EntityState.Deleted; //修改实体 //t_user user = new t_user(); //user.id = 5; //user.username = "ssss"; //context.Entry(user).State = System.Data.EntityState.Modified; //联合插入实体 UserInfo user = new UserInfo(); user.username = "123456"; user.times = DateTime.Now; context.Entry(user).State = System.Data.EntityState.Added; OrderInfo order = new OrderInfo(); order.orderName = "orderName"; //外键插入 order.UserInfo = user; context.Entry(order).State = System.Data.EntityState.Added; context.SaveChanges(); } } }
标签:style blog io color ar sp 数据 div on
原文地址:http://www.cnblogs.com/zoro-zero/p/4063662.html