public void AddItem(string who) { using (var db = new mapContext()) { // 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 AddUser(string emailAddress) { using (var db = new mapContext()) { Mapuser mu = new Mapuser { Email = emailAddress }; db.Mapuser.Add(mu); db.SaveChanges(); Console.WriteLine(mu.Id + " " + mu.Email); } }