/writing

Notes from production

Working notes on building .NET systems and integrating them with Business Central — the failures, trade-offs and design decisions that only show up once software is running for real.

EF Core: Why Your New Child Row Becomes a Phantom UPDATE

Assign entity IDs in the constructor and EF assumes anything it discovers already exists. The error names a concurrency problem you don't have.

Read it →

Effective-Dated Rules: Never Default to UtcNow

A rule that only applies from the moment its object was constructed is a rule that can't describe anything that happened before today.

Validate Your Rule Table at Startup, and Refuse to Boot

Config-driven rules have a failure mode code doesn't: a row naming something that no longer exists. Catch it at boot, not at 4pm.

Omit Actions the User Can't Take — Don't Render Them Disabled

A greyed-out button is an inventory of your permission model, handed to whoever hovers it.

A Refused Operation Is a Return Value, Not an Exception

"You may not do that yet" is an ordinary outcome. Throwing for it costs you the reason and flattens your HTTP responses.

Check Permission Before You Check Preconditions

The order of two `if` statements decides whether your error messages leak your business state to people who can't act.

Design Preconditions That Can't Become an N+1

If a validation rule can query the database, one day it will — inside a loop. Hand it facts instead.

Split Your Test Projects So a Wrong Dependency Won't Compile

One test project per layer isn't bureaucracy — it's how an accidental EF Core reference in a use case becomes a build failure.

Let the Compiler Enforce Your Architecture

Layering diagrams don't stop anyone. `internal` plus `InternalsVisibleTo` does — a bypass becomes a build error.

Your State Machine Should Be Data, Not a Workflow Engine

Statuses and permitted moves as rows; preconditions as code. The split that lets a business add a state without a release.