Reputation: 1
I am using Tracker-enabled-dbcontext with database first. With version 3.6 is there a way to have the system generate the auditlog and auditdetail tables? If not how would I go about doing this with database first? Can I create the tables and then just add them to my dbcontext? If so what is the structure of the tables?
Upvotes: 0
Views: 513
Reputation: 331
The author of the tool specifies that it will not currently work with Database First. My project uses Entity Framework but it's not Database First or Code First -- I create the model and database tables separately and tie them together with annotations. As such, I couldn't figure out how to build the AuditLog database tables.
I ended up downloading the Tracker-enabled-dbcontext source code from github. The source code includes a demo project. I updated the Web.config file so that the connection string pointed at the database where I wanted the tables to reside and ran it. It automatically created the necessary tables there. I had to delete all the extra tables that it created as part of the demo, but once the tables were in place, my project wrote the change data to them as expected.
Since the logging is tied to the DBContext, I had to create separate AuditLog tables in each of the databases that I wanted to track changes for. I tried to simply CREATE the tables in the second database using the definition from the first, but for some reason that didn't work, so I had to go through the whole Demo connection string procedure again.
Upvotes: 1