1

Our customer request the functionality of logging changes in db. We need next structure:

"Timestamp", "User", "DB.Table.Field changed", "Value after change"

What we have:

  • Entity Framework Code First
  • ELMAH
  • MySQL Data Base with more than 100 tables (changes should be tracked to all of them)

So we need:

  • Somehow track what table was changed
  • What new value was added/updated
  • Generic functionality (if possible)

Any ideas how to do this?

PS. ELMAH is not a strict requirement. But MySql is :)

Thank you!

Evgeniy Labunskiy
  • 2,012
  • 3
  • 25
  • 45

2 Answers2

0

Ultimately, what you're looking for is some sort of behavior that keeps track of auditing. ELMAH is not geared towards that.

You most likely want to look in to some sort of Polymorphic object that can keep track of who executed what type of action on a known entity. You're most likely going to want to use some sort of AOP concepts. Libraries like like DynamicProxy2, LinFu should be helpful in this area.

Your goal would be to use proxy objects that wrap your existing entities and "inject" the auditing information that you need to track.

Bryan Ray
  • 914
  • 11
  • 26
0

I actually had the same feature request and even though I wrote a tracking layer before for my generic repository I found that there is one available in Nuget/Github that handles this.

https://www.nuget.org/packages/TrackerEnabledDbContext/

https://github.com/bilal-fazlani/tracker-enabled-dbcontext

You can use this and I found that it works great for me. I use it into my Generic repository project.

txavier
  • 471
  • 4
  • 5