migrate-nullable-references

Enable nullable reference types in C# projects and resolve all CS86xx warnings.

Updated Jul 12, 2026
One-click install
npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill migrate-nullable-references-patrick-rex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-nullable-references
Source: https://github.com/Patrick-Rex/DotNetTechSamples/tree/main/.agents/plugins/dotnet-upgrade/skills/migrate-nullable-references
Command: npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill migrate-nullable-references-patrick-rex

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Migrating an existing C# codebase to nullable reference types produces hundreds of CS86xx warnings with no clear order of attack, and incorrect annotations silently change API contracts, EF Core schemas, and ASP.NET Core validation behavior. ## Core Features & Use Cases - Structured migration workflow: Seven-step process covering readiness evaluation, rollout strategy selection (project-wide, warnings-first, or file-by-file), dereference warning fixes, declaration annotation, nullable attributes, suppression cleanup, and validation. - Readiness scanner script: The Get-NullableReadiness.ps1 script reports <Nullable>, <LangVersion>, and <TargetFramework> settings plus counts of #nullable directives, null-forgiving operators, and pragma suppressions, with JSON output for automation. - Framework-specific guidance: Reference documents cover EF Core schema inference, ASP.NET Core model validation, nullable attribute usage, and library breaking-change tracking. - Use Case: A team enabling NRTs on a legacy .NET library uses the scanner to baseline 300 warnings, migrates core models first in dependency order, and ships a documented nullable-breaking-changes.md with the release. ## Quick Start Ask the AI to enable nullable reference types in your C# project and systematically resolve all resulting warnings using this migration workflow.

Frequently Asked Questions about migrate-nullable-references

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable nullable reference types in an existing C# project?

Add <Nullable>enable</Nullable> to the .csproj PropertyGroup, then build and resolve the resulting CS86xx warnings. For large codebases, use a warnings-first or file-by-file strategy with #nullable enable per file to keep the warning volume manageable.

How to fix CS8602 dereference of possibly null reference warnings?

Decide whether null is valid by design: add ? to the declaration if so, or use the null-forgiving operator ! only when you can prove the value is never null. Avoid using ?. as a quick fix since it silently changes runtime behavior.

Does enabling nullable reference types change runtime behavior?

For reference types, annotations are metadata-only and do not change generated IL. However, EF Core infers column nullability from annotations and ASP.NET Core treats non-nullable properties as required, so those frameworks can change behavior.

Can I use nullable reference types with .NET Framework or C# 7?

Nullable reference types require C# 8.0 or later, which means .NET Core 3.0, .NET Standard 2.1, or newer. Projects on .NET Framework 4.x need an explicit <LangVersion>8.0</LangVersion> or higher, and C# 7.3 or earlier cannot use the feature.

When should I use null-forgiving operator vs making a type nullable?

Use ! only when you can prove the value is never null but the compiler cannot see why, and add a comment explaining the reasoning. If null is a valid state by design, annotate the type with ? instead of suppressing the warning.

Why does enabling NRTs cause EF Core migration changes?

EF Core reads nullable annotations via reflection and treats string properties as required NOT NULL columns while string? becomes nullable. Always review generated migrations after enabling NRTs on entity classes to avoid unintended AlterColumn operations on columns containing nulls.