Context.Add not adding

2 posts, 0 answers
  1. Rui
    Rui avatar
    30 posts
    Member since:
    Feb 2012

    Posted 04 Jul 2012 Link to this post

    Hello, I've a call to context.Add(entityX), everything seems to be nice, but is not. 
    When I do a Context.GetChanges().GetInserts it returns 0.
    No error is raised. And goes good throw the events :
    •  void Events_Added(object sender, AddEventArgs e)
    • void Events_Adding(object sender, AddEventArgs e)

    How can his be debugged?



  2. Rui
    Rui avatar
    30 posts
    Member since:
    Feb 2012

    Posted 04 Jul 2012 Link to this post

    Found the problem... never mind. 
    For those who encounter a similar problem see if context.GetHashCode is always the same.

    In my case, by mistake in a base class, I was instantiating a new Context on every context call.
    In my case the context is a property in a base class that lives in all the class life time.

    Anyway, I keep the post just in case someone else need it.
     Thank you

  3. DevCraft banner
Back to Top