public void TestMethod1() { using (var ctx = new GuardianContext()) { User u = new User(); u.Email = "*****@*****.**"; u.Name = "VR"; ctx.Users.Add(u); ctx.SaveChanges(); Profile pr = new Profile(); pr.User = u; pr.RegionCode = "+91"; ctx.Profiles.Add(pr); ctx.SaveChanges(); } }
//ssm public async Task <bool> SaveMarshal(int groupID, long profileID, bool isValidated) { GroupMarshal grpMarshal = new GroupMarshal() { GroupID = groupID, ProfileID = profileID, IsValidated = isValidated }; if (!isValidated) { grpMarshal.CreatedDate = DateTime.UtcNow; grpMarshal.LastModifiedDate = DateTime.UtcNow; _guardianContext.GroupMarshals.Add(grpMarshal); _guardianContext.SaveChanges(); } else { grpMarshal.LastModifiedDate = DateTime.UtcNow; _guardianContext.Entry <GroupMarshal>(grpMarshal).State = EntityState.Modified; _guardianContext.SaveChanges(); } return(true); }
public void DeleteUsingEFTest() { using (var ctx = new GuardianContext()) { //User u = new User() { Name = "VR" };//Not working User u = new User() { UserID = 2 }; // working ctx.Entry(u).State = EntityState.Deleted; ctx.SaveChanges(); } }