Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Build Web APIs Faster with .NET Core Scaffolding
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Anthony Sneed
June 14, 2018
Technology
0
92
Build Web APIs Faster with .NET Core Scaffolding
Anthony Sneed
June 14, 2018
Tweet
Share
More Decks by Anthony Sneed
See All by Anthony Sneed
Build Web APIs Faster with .NET Core Scaffolding
tonysneed
0
55
EF Core with Patterns
tonysneed
0
260
Follow Your IT Dreams
tonysneed
0
72
Dockerising ASP.NET Core Applications
tonysneed
1
140
Fun with Visual Studio Code
tonysneed
0
130
Other Decks in Technology
See All in Technology
型を書かないRuby開発への挑戦
riseshia
0
200
モブプログラミング再入門 ー 基本から見直す、AI時代のチーム開発の選択肢 ー / A Re-introduction of Mob Programming
takaking22
4
590
Agentic Software Modernization - Back to the Roots (Zürich Agentic Coding and Architectures, März 2026)
feststelltaste
1
210
技術的負債の泥沼から組織を救う3つの転換点
nwiizo
8
3k
us-east-1 に障害が起きた時に、 ap-northeast-1 にどんな影響があるか 説明できるようになろう!
miu_crescent
PRO
13
3.8k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
22k
EMからVPoEを経てCTOへ:マネジメントキャリアパスにおける葛藤と成長
kakehashi
PRO
9
1.3k
OpenClawで回す組織運営
jacopen
3
630
AWS DevOps Agent vs SRE俺 / AWS DevOps Agent vs me, the SRE
sms_tech
3
350
GitLab Duo Agent Platform + Local LLMサービングで幸せになりたい
jyoshise
0
180
Data Hubグループ 紹介資料
sansan33
PRO
0
2.8k
オンプレとGoogle Cloudを安全に繋ぐための、セキュア通信の勘所
waiwai2111
3
1.1k
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
55
12k
So, you think you're a good person
axbom
PRO
2
1.9k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
660
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
53k
Mobile First: as difficult as doing things right
swwweet
225
10k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
370
Balancing Empowerment & Direction
lara
5
930
Rails Girls Zürich Keynote
gr2m
96
14k
Building the Perfect Custom Keyboard
takai
2
710
Transcript
Build Web APIs Faster With .NET Core Scaffolding Tony Sneed
and Long Le
About Tony • Sr. Solutions Architect @ www.hilti.com • Coding
C# since v1 • Author / Instructor: DevelopMentor, Wintellect • Open Source: URF, Trackable Entities ASPNET Core, EF Core • blog.TonySneed.com • Twitter: @tonysneed
About Le • Sr. Solutions Architect @ www.hilti.com • Currently
geeking out with MEAN & .NET Core • Open Source: URF.Core, Trackable Entities • blog.longle.io • Twitter: @lelong37
Problem: Boilerplate code is time-consuming and boring!
Solution: .NET Core code scaffolding to the rescue!
Part 1: Intro to .NET Core Scaffolding
What is .NET Core Scaffolding? • Reverse engineer entity and
EF Core context classes from existing database • Create Web API controllers with CRUD operations based on EF Core context class
Scaffolding Approaches • Visual Studio wizards - EF Core Power
Tools - Add New Controller wizard - Visual Studio only - Windows only • Command line - .NET Core CLI - VS Code or Visual Studio - Cross-platform
EF Core: Not Your Father’s EF • Re-written from the
ground up! • .NET Standard 2.0 • Cross-Platform, Containers, Cloud Friendly • Modern, Modular, Extensible • Lightweight, Performant
Migrate from EF6 to Core? Don’t even think about it!
EF Core Power Tools • Reverse engineer • Visualize model
• Customize entity classes (Handlebars templates*) * Tony’s contrib :)
EF Core CLI • Cross Platform - Compatible with VS
Code on Windows or Mac • Flexible Options - Output entities and context to different projects
Project Structure • Entities: NET Standard 2.0 class library -
Compatible across all flavors of .NET • DbContext: .NET Core class library - EF Core CLI requires .NET Core • Web API: ASP.NET Core Project - Reference Entities and Data projects
Customizing Code Generation • Handlebars Templates - Double curly model
binding - Partial templates - Helper methods • IDesignTimeServices implementation - services.AddHandlebarsScaffolding • https://github.com/TrackableEntities/ EntityFrameworkCore.Scaffolding.Handlebars
Scaffolding Web API Controllers • Razor Templates - C# Syntax
- Partial templates - Helper methods • .NET Core CLI - dotnet new -i “AspNetCore.WebApi.Templates::*" • https://github.com/TrackableEntities/ AspNetCore.ApiControllers.Templates
None
Part 2: Design Patterns for EF Core
Why Patterns? • Using EF directly couples your app to
EF • Newing up DbContext makes your app less testable
Repository Pattern • Repository interfaces decouple app from persistence concerns
Sample Repository public class ProductRepository : IProductRepository { private readonly
NorthwindContext _dbContext; public ProductRepository(NorthwindContext dbContext) { _dbContext = dbContext; } public async Task<Product> FindAsync(int id) { return await _dbContext.Products.FindAsync(id); } }
Marking Changes public void Insert(Product product) { // Mark Added
_dbContext.Products.Add(product); } public void Update(Product product) { // Mark Modified _dbContext.Products.Update(product); } public async Task Delete(int id) { // Mark Deleted var product = await _dbContext.Products.FindAsync(id) _dbContext.Products.Remove(product); }
Unit of Work Pattern • Save changes from multiple repositories
• Wrapped in a single transaction
Persisting Changes public interface IUnitOfWork { Task<int> SaveChangesAsync(); }
Dependency Injection • DI container responsible for supplying instances •
DI is built into ASP.NET and EF Core
Helpful Frameworks • URF: Generic Unit of Work and Repository
https://github.com/urfnet/URF.Core
Helpful Frameworks • Trackable Entities: N-Tier Support for EF Core
https://github.com/TrackableEntities/ TrackableEntities.Core
None
Thank You! Tony Sneed: @tonysneed Long Le: @lelong37 Slides: https://speakerdeck.com/tonysneed/ef-core-with-patterns
Bits: https://github.com/tonysneed/Demo.EfCore.Patterns
Thank You! Tony Sneed: @tonysneed Long Le: @lelong37 Slides: https://speakerdeck.com/tonysneed/ef-core-with-patterns
Bits: https://github.com/tonysneed/Demo.EfCore.Patterns