Wednesday, April 13, 2016

Entity Framework - Store update, insert, or delete statement affected an unexpected number of rows (0)

This error can have several causes, in my case it was that I had forgotten to create the PK and identity columns in a table. More complex causes can be found here

Saturday, April 9, 2016

PowerShell - "AuthorizationManager check failed" from Octopus Deploy

I came across this error when trying to run Import-Module in an Octopus Deploy PowerShell script. This script was in the source code. What I end up doing was taking out Import-Module into its own Octopus Deploy step "Run a Script".

This article also thoroughly explain the reason for the error

In the process, I also learned that Octopus Deploy changes the execution policy of the Powershell process to unrestricted.

Wednesday, April 6, 2016

Tracking changes in a database in a .NET project

Java has a very neat package to do this, called torque. In .NET we're not quite there yet, so I highly recommend for .NET projects. Here are some things to keep in mind:

1) It will log all changes into only 2 (master-detail) tables (instead of having as many tables as entities as in torque).
2) You need to create those 2 tables manually, the schema is derived from screenshots in the wiki of the project (don't forget your PK's).
3) Setting it up is quite simple, only annotate the entities you want to track and inherit from TrackerContext instead of DbContext.