zzzprojects / GraphDiff

GraphDiff is a library that allows the automatic update of a detached graph using Entity Framework code first.
https://entityframework-graphdiff.net/overview
MIT License
333 stars 102 forks source link

DatabaseGenerated if column not being set #134

Closed cryo75 closed 9 years ago

cryo75 commented 9 years ago

I'm using UpdateGraph also for inserting entiies, as follows:

    public override void Add(Customer entity)
    {
        this.Update(entity);
    }

    public override Customer Update(Customer entity)
    {
        return ((DbContext)dataContext).UpdateGraph<Customer >
            (entity,
                map => map.AssociatedEntity(x => x.CustomerType)
            );
    }

However, Customer id is still 0 after calling SaveChanges. The customer is still being added in the db with a valid id.

What could be wrong here?

josh-dastmalchi commented 9 years ago

In this code sample, you aren't using the return value of UpdateGraph, so you don't have a reference to the updated entity.

cryo75 commented 9 years ago

Thats that did the trick.!