1

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; }
3
  • can you show your context class and conn string? Commented Oct 28, 2016 at 16:28
  • As for the connection string, it is connecting to the DB since I do get results when I loop through the tables in other portions of the code Commented Oct 28, 2016 at 16:34
  • OK,now can you show the conn string too ? Commented Oct 28, 2016 at 16:38

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.