Mauro Servienti moves an ASP.NET Core controller onto ServiceComposer's contract-less composition handlers route by route, then splits it by data ownership, documenting the casing, status-code, threading and transaction gotchas that surface along the way.
Key points
- ServiceComposer and controllers can coexist in one ASP.NET Core app; MapCompositionHandlers() serves the migrated routes.
- AddHttpContextAccessor() and UseOutputFormatters = true are required so handlers can set 404 and 204 action results.
- Without DictionaryKeyPolicy camel case, composed responses serialize dictionary keys as Id while controllers return id, breaking clients.
- A route cannot be mapped by both a controller action and composition handlers; ASP.NET throws AmbiguousMatchException.
- Handlers execute concurrently, so each one creates its own scope and DbContext; a shared scoped DbContext is not thread-safe.
- After the split, a POST is no longer one transaction: Sales can commit the price while Marketing fails.
Real-world use
- An online store product endpoint where Marketing owns the name and description while Sales owns the price.
- A monolith on a single Products table that must keep its API contract stable while services are separated step by step.
- Write endpoints where price and description can be saved independently instead of in one atomic request.
This summary was generated by the agent from the original post on Mauro Servienti. The full text and all rights belong to its author and publisher. Go to original