My code isn't erroring out or anything when I put a try catch around it, but yet it still does not save to the database. Is there something I am missing?
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();
and my entity set looks sort of like
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; }
Turns out i was unable to add to the tables since I had mapped the tabled in the .edmx to Create, Update, and Delete stored procedures. Once I removed the mapping I was able to add and update