NickStrupat / EntityFramework.Triggers

Adds events for entity inserting, inserted, updating, updated, deleting, and deleted
MIT License
373 stars 46 forks source link

Updated field is not getting saved to the Database #30

Closed gregoryagu closed 6 years ago

gregoryagu commented 6 years ago

I have a core project set up just like the sample.

The trigger fires and sets the Updated field with the current date/time.

But it doesn't get persisted to the database.

Triggers<TrackableEntity>.Updating += entry =>
{
    entry.Entity.Updated = DateTime.Now;
};

I don't see what I am doing wrong.

gregoryagu commented 6 years ago

Well, I got this working by removing the private set.

public DateTimeOffset Updated { get; set; }

In the example it shows:

public DateTimeOffset Updated { get; private set; }

You might want to update the docs.

Oddly, it did not give an error, it just failed to save it.