private static void AddUser(mapContext db, string emailAddress) { Mapuser mu = new Mapuser { Email = emailAddress }; db.Mapuser.Add(mu); db.SaveChanges(); Console.WriteLine(mu.Id + " " + mu.Email); }
private static void AddItem(mapContext db, string who) { // get the user var me = db.Mapuser .Single(u => u.Email.ToString() == who); // get the first action var action = db.Actions .Single(i => i.Id == 1); // New up an object var ua = new Useractions(); ua.Actions = action; ua.User = me; ua.Actiondate = DateTime.Now; // Save it db.Useractions.Add(ua); db.SaveChanges(); // if it returns an ID, we're good Console.WriteLine("Done: " + ua.Id); }
public void Commit() { dataContext.SaveChanges(); }