Entity Framework SaveChanges not saving to the database

c# ef-code-first entity-framework entity-framework-6

Question

When I put a try catch around my code, nothing fails or errors out, but the database still isn't saved. Is there anything I'm overlooking?

var newGroupMemberOf = new GroupMemberOf();
newGroupMemberOf.SamAcName = accountName;
newGroupMemberOf.MemberOf = parentSameAcName;
newGroupMemberOf.DateCreated = DateTime.Now;
newGroupMemberOf.DateUpdated = DateTime.Now;
newGroupMemberOf.IsActive = true;
newGroupMemberOf.Hidden = hidden;
newGroupMemberOf.ID = 12345678;

UserEntities.GroupMemberOf.Add(newGroupMemberOf);

UserEntities.SaveChanges();

also, my entity set resembles

public partial class UsersEntities : DbContext 
{ 
 public UsersEntities() 
    : base("name=UsersEntities") 
{ 
} 

protected override void OnModelCreating(DbModelBuilder modelBuilder) 
 {
  throw new UnintentionalCodeFirstException(); 
 }

 public virtual DbSet<GroupMemberOf> GroupMemberOf { get; set; }
1
1
10/28/2016 5:45:38 PM

Popular Answer

ZZZ_tmp
1
10/28/2016 9:16:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow