Search code examples
.netentity-frameworknhibernateormscd

.NET ORM Framework with data versioning (Slowly Changing Dimension Type 2)?


I am building a .NET application for inserting data (an Excel add-in in fact), and I want to use an ORM for inserting data with automated versioning.

Here's a worked example:

  • User "John Doe" does the first data insertion (4 data points as per below example)
  • At a later time, user "Albert" opens the interface, modifies one data point, and saves
  • All 4 data points are processed; ORM flags the modified data as non-Current, adds the new data, updates version counter, changes validity dates columns

JOHNDOE and ALBERT insert data one after the other...

I am looking for an ORM framework that would automatically take care of the versioning. Below, the database table after the second insertion. Those familiar with DB schemas will recognize this as a "Slowly Changing Dimension (SCD) Type 2"

enter image description here

The data will be accessed not via the ORM, but from various SQL queries, so the valid_from/valid_to columns are essentials. I am also aware that this can be done with database triggers but I want a solution that works regardless of back-end...


Solution

  • Finally found something.

    NHibernate has a versioning extension, Envers.

    http://www.primordialcode.com/blog/post/nhibernate-envers-quick-introduction

    It will create both last-version tables and versioned tables. It won't call it a "Slowly Changing Dimension", but the versioning strategy is equivalent (as opposed to creating a table for each measure to version)

    Schema below.

    Example Schema