ASP.NET Core MVC

Refactor ASP.NET Core MVC apps into thin controllers, ViewModels, and isolated EF Core data layers.

1|Updated May 2, 2026
One-click install
npx skills add https://github.com/Levironexe/architect --skill asp-net-core-mvc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ASP.NET Core MVC
Source: https://github.com/Levironexe/architect/tree/main/skills/stacks/aspnetcore-mvc
Command: npx skills add https://github.com/Levironexe/architect --skill asp-net-core-mvc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

ASP.NET Core codebases often drift into “fat controllers,” EF entity leakage into Razor views, tangled business rules in UI templates, and unclear separation between HTTP, business logic, and data access. This Skill guides a coding agent to restructure the project into a predictable ASP.NET Core MVC layout with thin controllers, dedicated ViewModels, and service-injected business logic.

Core Features & Use Cases

  • Thin controller enforcement: Ensures controller actions validate inputs, delegate to injected services, and return Views with ViewModels (no ORM queries or business rules inside controllers).
  • Razor view separation: Keeps Razor views focused on display logic using a dedicated ViewModel as the @model, avoiding .SaveChanges() and @inject calls for business decisions.
  • ViewModel-first modeling: Establishes clear InputModels (validated form submissions via Data Annotations) and Output ViewModels (only the data the view needs), mapped in the service layer.
  • Data layer isolation with EF Core: Directs DbContext and EF/repository logic into a Data/ layer, injected where needed but never used directly from controllers.
  • Page-centric flow guidance: Recommends Razor Pages for self-contained features, while supporting MVC structure for controller/action-centric flows (including Area organization for larger apps).

Quick Start

Use the ASP.NET Core MVC skill to guide your agent to reorganize controllers, views, ViewModels, and EF Core access into a clean, testable structure starting from your current Program.cs, Program wiring, and existing Views/ or Pages/.

Frequently Asked Questions about ASP.NET Core MVC

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

FAQPage Schema
How do I refactor fat controllers in ASP.NET Core MVC to separate business logic?

To refactor fat controllers in ASP.NET Core MVC, enforce thin controller patterns by validating inputs via ModelState, delegating business logic to injected services, and returning Views with dedicated ViewModels instead of querying EF Core directly.

How do I stop EF Core entity leakage into Razor views?

Stop EF Core entity leakage by establishing ViewModel-first modeling, where a dedicated ViewModel acts as the sole @model for Razor views, ensuring entity types are mapped to Output ViewModels in the service layer and never passed directly to the UI.

What is the best way to structure ViewModels and InputModels for ASP.NET Core MVC forms?

The best way to structure ViewModels is to create clear InputModels for validated form submissions using Data Annotations, and Output ViewModels containing only the data the view needs, mapped entirely within the injected service layer.

Does this refactoring approach work for page-centric Razor Pages flows or only controller-action MVC?

This refactoring approach supports both controller-action MVC and page-centric flows, recommending self-contained Razor Pages for specific features while utilizing MVC structure and Area organization for larger controller-centric applications.

Where should I isolate DbContext and EF Core repository logic during an MVC refactoring?

Isolate DbContext and EF Core repository logic in a dedicated Data/ layer during your MVC refactoring, injecting these services where needed but ensuring they are never used directly from controllers or Razor views.

Why should business logic be removed from Razor templates in ASP.NET Core MVC?

Business logic should be removed from Razor templates to enforce clean separation of concerns, preventing tangled UI rules and ensuring Razor views focus solely on display logic using a dedicated ViewModel rather than injecting services for decisions.