Create self signed certificate

Today i started a project what utilized IdentityServer and for that i needed a signed certificate. This post might not be the best explained, but more like a reminder for my self. param ( [Parameter(Mandatory=$true)][string]$subject = “My SelfSigned Certificate”, [string]$outputPath = (Get-Item -Path “.\” -Verbose).FullName, [Parameter(Mandatory=$true)][string]$password #[string]$password = $( Read-Host “Input password, please” ) ) […]

Map private fields in Entity framework core

In DDD you always want to control what is being put into your domain object. That can be done with public getters and private setters. But when it comes to collections (e.g. System.Collections.Generic.List<T>) it becomes more complicated, due to the fact the the domain object exposes an object of type List<T> which can be modified.

Testing DBContext migrations

Today i was creating EntityFrameworkCore DBContexts and it’s a time consuming work to delete the databases, add migrations and then update the database to see what the migration scripts would generate. I created a simple powershell-script that i ran when needed. Write-Host “Deleting the migrations folder…” Remove-Item “Migrations” -Force -Recurse Write-Host “Dropping database ASPD..” sqlcmd […]

State pattern in C#

The state design patterns is a behavioral pattern that implements a state machine in an object-oriented way. It allows an object/class to alter its behavior when its internal state changes. Lets say that we have a competition application that allows clients to register score, but only when the competition is open. A non state pattern design […]