Skip to main content

Posts

Showing posts from January, 2015

Quick and easy table Audit with code first EF6 and Migrations

For one of my current projects, we had a requirement to create track changes made to two tables in the database for auditing purposes. Initially I thought we could just use the built in SQL change tracking features (here), however we were deploying this application to Azure and as of now, that feature is not available in SQL Azure.
I did some investigating into this and there were a few options:
Option 1: Create my own triggers on these tables and write data to the audit tables when the rows were updated. This was some what straight forward, but I’m not a fan of triggers and I wanted to keep all of my code in C#/Entity Framework for ease of code management down the road. Also, I didn’t want to have to update the triggers when the table was altered
Option 2: Implement this work around leveraging a Local data cache While this seems like an easier approach, I wouldn’t be fully in control of what was happening during updates. Also, this approach only tells you what rows have changed an…