Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
© Betabit Nederland B.V.
Oscar van Tol
o.van.tol@betabit.nl
@oscarvantol
Rick van den Bosch
r.van.den.bosch@betabit.nl
@ri...
© Betabit Nederland B.V.
Who’s who?
Oscar van Tol Rick van den Bosch
© Betabit Nederland B.V.
The plan
.NET Core - the basics
Why the reboot
.NET Standard
Tooling *
EF Core *
Caffeine
ASP.NET...
© Betabit Nederland B.V.
.NET Core - the basics
© Betabit Nederland B.V.
.NET Core
“.NET Core is a general purpose development platform maintained by Microsoft and the
.N...
© Betabit Nederland B.V.
What is .NET Core 1/2
• Flexible deployment: Can be included in your app or installed side-by-sid...
© Betabit Nederland B.V.
What is .NET Core 2/2
• Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono...
© Betabit Nederland B.V.
© Betabit Nederland B.V.
Why the reboot
.NET Framework was too monolithic​
Too many dependencies (preventing cross-platfor...
© Betabit Nederland B.V.
.NET Standard
Multiple runtimes:​
• Reusing code?​
• Dependencies?​
• Creating libraries?​
• OS r...
© Betabit Nederland B.V.
© Betabit Nederland B.V.
.NET Standard
We have Portable Class Libraries (PCL) for that. Right?
• Target ‘least common deno...
© Betabit Nederland B.V.
.NET Standard
• A version of the .NET Standard is a definition of a collection of standard Api’s....
© Betabit Nederland B.V.
.NET Standard: versions
© Betabit Nederland B.V.
So what do we do with PCL?
© Betabit Nederland B.V.
.NET Standard 2.0
© Betabit Nederland B.V.
.NET Core SDK
Command line tools
Libraries & runtime
dotnet driver (CLI)
Primary layer
Cross plat...
© Betabit Nederland B.V.
DEMO
.NET Core Tooling
© Betabit Nederland B.V.
dotnet.exe
new
migrate
restore
run
build
test
publish
pack
Meer info: http://bit.ly/nyddn-cmds
© Betabit Nederland B.V.
EF Core
© Betabit Nederland B.V.
EF Core
“EF Core is a lightweight, extensible, and cross-platform version of the popular Entity
F...
© Betabit Nederland B.V.
EF Core
Lightweight
Extensible
Cross-platform
© Betabit Nederland B.V.
EF Core
Not complete!
EF6.x is still alive and will continue to be updated.
https://github.com/as...
© Betabit Nederland B.V.
Which one is right for you?
EF6.x most suitable for most applications
Use EF Core:
• In new appli...
© Betabit Nederland B.V.
DEMO
Entity Framework Core
© Betabit Nederland B.V.
Hands on with .NET Core?
Workshop .NET Core
@Betabit Utrecht
Hands on
Registration form available...
© Betabit Nederland B.V.
WINACTIE
Wat: Security workshop
Waar: Betabit Utrecht
Wanneer: 5 & 6 juni 2017
Lever het formulie...
© Betabit Nederland B.V.
Lets have a <br>
Warning: we really respect your privacy and EU law requirements require us to in...
© Betabit Nederland B.V.
ASP.NET Core
© Betabit Nederland B.V.
ASP.NET Core
“ASP.NET Core is a new open-source and cross-platform framework for building modern
...
© Betabit Nederland B.V.
ASP.NET Core
ASP.NET Core != .NET Core
Can target .NET Core and Full Framework
Develop & run on W...
© Betabit Nederland B.V.
Why ASP.NET Core?
ASP.NET 1st version: 15 years ago
Lots of added & evolved capabilities
Much lea...
© Betabit Nederland B.V.
ASP.NET Core – Startup
Startup class is required
Constructor can accept dependencies provided by ...
© Betabit Nederland B.V.
ASP.NET Core – Middleware
Assembled into pipeline
Handles requests and responses
Calls next or sh...
© Betabit Nederland B.V.
ASP.NET Core – Middleware example
© Betabit Nederland B.V.
What’s ‘wrong’ here…???
© Betabit Nederland B.V.
ASP.NET Core – Configuration
Configure app based on a list of name-value pairs
Can be read at run...
© Betabit Nederland B.V.
ASP.NET Core – Options pattern
Uses custom options classes to represent a group of related settin...
© Betabit Nederland B.V.
ASP.NET Core – Hosting
ASP.NET Core requires a host in which to execute
Must implement IWebHost
T...
© Betabit Nederland B.V.
ASP.NET Core – Web server
ASP.NET Core runs with an in-process HTTP Server implementation
Listens...
© Betabit Nederland B.V.
ASP.NET Core – Kestrel
Included by default
Internal facing: just Kestrel
Internet facing: IIS, Ng...
© Betabit Nederland B.V.
ASP.NET Core – WebListener
Internal facing: WebListener
Internet facing (without IIS): WebListene...
© Betabit Nederland B.V.
ASP.NET Core Web API
What's new?
• Nothing, it's gone
• Use MVC 6 for REST
• No major issues migr...
© Betabit Nederland B.V.
DEMO
ASP.NET Core Web API
© Betabit Nederland B.V.
ASP.NET Core MVC
What’s new?
• wwwroot
• Razor syntax
• Tag helpers
• Dependency Injection in Vie...
© Betabit Nederland B.V.
wwwroot
Meant for static files
Add static file middleware
URLs for static content are relative to...
© Betabit Nederland B.V.
Razor & Tag helpers
© Betabit Nederland B.V.
DI into views
@inject (adds a ‘property’ to your view
Can be usefull for View-specific services (...
© Betabit Nederland B.V.
DEMO
ASP.NET Core MVC
© Betabit Nederland B.V.
ASP.NET or ASP.NET Core?
© Betabit Nederland B.V.
Recap
.NET Core
Command line interface
.NET Standard
Entity Framework Core
ASP.NET Core
© Betabit Nederland B.V.
FINAL DEMO
© Betabit Nederland B.V.
FX: To Core or not to Core?
.NET Core .NET Framework
Cross-platform needs Currently using .NET
Ta...
© Betabit Nederland B.V.
What's next
source: https://github.com/dotnet/core/blob/master/roadmap.md
© Betabit Nederland B.V.
Did you know?
© Betabit Nederland B.V.
Resources
.NET Core Source Browser https://source.dot.net
dotnet.exe commands http://bit.ly/nyddn...
© Betabit Nederland B.V.
Bedankt voor je aandacht
© Betabit Nederland B.V.
© Betabit Nederland B.V.
Upcoming SlideShare
Loading in …5
×

.Net Core - not your daddy's dotnet

754 views

Published on

Presentation for the .NET Event about .NET Core @Betabit Rotterdam. Sourcecode for the demos will also be available online, probably through GitHub.

Published in: Software
  • Be the first to comment

.Net Core - not your daddy's dotnet

  1. 1. © Betabit Nederland B.V. Oscar van Tol o.van.tol@betabit.nl @oscarvantol Rick van den Bosch r.van.den.bosch@betabit.nl @rickvdbosch .NET Core Not your daddy’s DOT NET
  2. 2. © Betabit Nederland B.V. Who’s who? Oscar van Tol Rick van den Bosch
  3. 3. © Betabit Nederland B.V. The plan .NET Core - the basics Why the reboot .NET Standard Tooling * EF Core * Caffeine ASP.NET Core ASP.NET Core – Web API * ASP.NET Core – MVC * What’s next * == code!
  4. 4. © Betabit Nederland B.V. .NET Core - the basics
  5. 5. © Betabit Nederland B.V. .NET Core “.NET Core is a general purpose development platform maintained by Microsoft and the .NET community on GitHub. It is cross-platform, supporting Windows, macOS and Linux, and can be used in device, cloud, and embedded/IoT scenarios.” source: https://docs.microsoft.com/en-us/dotnet/articles/core
  6. 6. © Betabit Nederland B.V. What is .NET Core 1/2 • Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide.​ • Cross-platform: Runs on Windows, macOS and Linux; can be ported to other OSes. The supported Operating Systems (OS), CPUs and application scenarios will grow over time, provided by Microsoft, other companies, and individuals.​ • Command-line tools: All product scenarios can be exercised at the command-line.
  7. 7. © Betabit Nederland B.V. What is .NET Core 2/2 • Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.​ • Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses. Documentation is licensed under CC-BY. .NET Core is a .NET Foundation project.​ • Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support
  8. 8. © Betabit Nederland B.V.
  9. 9. © Betabit Nederland B.V. Why the reboot .NET Framework was too monolithic​ Too many dependencies (preventing cross-platform)​ Maintaining compatibility slowed down Framework development​ Removed dependency on OS​ Faster startup​ New runtime next to full framework (maintaining compatibility)
  10. 10. © Betabit Nederland B.V. .NET Standard Multiple runtimes:​ • Reusing code?​ • Dependencies?​ • Creating libraries?​ • OS related stuff? (for example: disk access)​
  11. 11. © Betabit Nederland B.V.
  12. 12. © Betabit Nederland B.V. .NET Standard We have Portable Class Libraries (PCL) for that. Right? • Target ‘least common denominator’ API for platforms • Not a sustainable model
  13. 13. © Betabit Nederland B.V. .NET Standard • A version of the .NET Standard is a definition of a collection of standard Api’s.​ • A runtime can support one or more versions of the .NET Standard.​ • A library can target one or more versions of the .NET Standard.​
  14. 14. © Betabit Nederland B.V. .NET Standard: versions
  15. 15. © Betabit Nederland B.V. So what do we do with PCL?
  16. 16. © Betabit Nederland B.V. .NET Standard 2.0
  17. 17. © Betabit Nederland B.V. .NET Core SDK Command line tools Libraries & runtime dotnet driver (CLI) Primary layer Cross platform
  18. 18. © Betabit Nederland B.V. DEMO .NET Core Tooling
  19. 19. © Betabit Nederland B.V. dotnet.exe new migrate restore run build test publish pack Meer info: http://bit.ly/nyddn-cmds
  20. 20. © Betabit Nederland B.V. EF Core
  21. 21. © Betabit Nederland B.V. EF Core “EF Core is a lightweight, extensible, and cross-platform version of the popular Entity Framework data access technology. It is an object-relational mapper that enables .NET developers to work with a database using .NET objects. It eliminates the need for most of the data-access code that developers usually need to write” source: https://docs.microsoft.com/en-us/ef/core
  22. 22. © Betabit Nederland B.V. EF Core Lightweight Extensible Cross-platform
  23. 23. © Betabit Nederland B.V. EF Core Not complete! EF6.x is still alive and will continue to be updated. https://github.com/aspnet/EntityFramework6 “very much a v1 product” Not Supported: Complex/value types, Simple type conversions, Spatial data types, Many-to-many without join entity, Lazy loading, Simple ccommand interception, Stored procedure mapping, Update model from database, Seed data, …
  24. 24. © Betabit Nederland B.V. Which one is right for you? EF6.x most suitable for most applications Use EF Core: • In new applications that do not require missing features • In applications that target .NET Core “You should view the move from EF6.x to EF Core as a port rather than an upgrade”
  25. 25. © Betabit Nederland B.V. DEMO Entity Framework Core
  26. 26. © Betabit Nederland B.V. Hands on with .NET Core? Workshop .NET Core @Betabit Utrecht Hands on Registration form available on the tables
  27. 27. © Betabit Nederland B.V. WINACTIE Wat: Security workshop Waar: Betabit Utrecht Wanneer: 5 & 6 juni 2017 Lever het formulier vandaag in! Let op! Maandag 5 juni is 2de pinksterdag
  28. 28. © Betabit Nederland B.V. Lets have a <br> Warning: we really respect your privacy and EU law requirements require us to inform you that this caffeine break will contain cookies. [accept]
  29. 29. © Betabit Nederland B.V. ASP.NET Core
  30. 30. © Betabit Nederland B.V. ASP.NET Core “ASP.NET Core is a new open-source and cross-platform framework for building modern cloud based internet connected applications, such as web apps, IoT apps and mobile backends.” source: https://docs.microsoft.com/en-us/aspnet/core
  31. 31. © Betabit Nederland B.V. ASP.NET Core ASP.NET Core != .NET Core Can target .NET Core and Full Framework Develop & run on Windows, Mac or Linux
  32. 32. © Betabit Nederland B.V. Why ASP.NET Core? ASP.NET 1st version: 15 years ago Lots of added & evolved capabilities Much leaner and more compact No longer based on System.Web.dll (but on NuGet packages) Tighter security Reduced servicing Improved performance Decreased costs in pay-per-use model
  33. 33. © Betabit Nederland B.V. ASP.NET Core – Startup Startup class is required Constructor can accept dependencies provided by DI IHostingEnvironment ILoggerFactory Must include Configure method Adding middleware Can include ConfigureServices Called before Configure Setup DI etc.
  34. 34. © Betabit Nederland B.V. ASP.NET Core – Middleware Assembled into pipeline Handles requests and responses Calls next or short-circuits the chain In-line or reusable Executed in order! Critical to security, performance and functionality
  35. 35. © Betabit Nederland B.V. ASP.NET Core – Middleware example
  36. 36. © Betabit Nederland B.V. What’s ‘wrong’ here…???
  37. 37. © Betabit Nederland B.V. ASP.NET Core – Configuration Configure app based on a list of name-value pairs Can be read at runtime from multiple sources Supports • File formats (INI, JSON and XML) • Command-line arguments • Environment variables • In-memory .NET objects • An encrypted user store • Azure Key Vault • Custom providers (install or create)
  38. 38. © Betabit Nederland B.V. ASP.NET Core – Options pattern Uses custom options classes to represent a group of related settings Enables using decoupled classes for each feature Interface Segregation Principle (ISP) Separation of Concerns IOptionsSnapshot supports reloading configuration on file change
  39. 39. © Betabit Nederland B.V. ASP.NET Core – Hosting ASP.NET Core requires a host in which to execute Must implement IWebHost Typically created using WebHostBuilder Responsible for application startup and lifetime management
  40. 40. © Betabit Nederland B.V. ASP.NET Core – Web server ASP.NET Core runs with an in-process HTTP Server implementation Listens for HTTP Requests Surfaces them to application as sets of request features composed into an HttpContext ASP.NET Core ships with two server implementations: • Kestrel (Cross-platform, based on Libuv) • WebListener (Windows-only, based on Http.Sys)
  41. 41. © Betabit Nederland B.V. ASP.NET Core – Kestrel Included by default Internal facing: just Kestrel Internet facing: IIS, Nginx or Apache as reverse proxy
  42. 42. © Betabit Nederland B.V. ASP.NET Core – WebListener Internal facing: WebListener Internet facing (without IIS): WebListener Internal facing: Kestrel recommended, unless WebListener features needed
  43. 43. © Betabit Nederland B.V. ASP.NET Core Web API What's new? • Nothing, it's gone • Use MVC 6 for REST • No major issues migrating (Microsoft.AspNetCore.Mvc.WebApiCompatShim) • Heads up: Json formatting now default in camelCase
  44. 44. © Betabit Nederland B.V. DEMO ASP.NET Core Web API
  45. 45. © Betabit Nederland B.V. ASP.NET Core MVC What’s new? • wwwroot • Razor syntax • Tag helpers • Dependency Injection in Views • …
  46. 46. © Betabit Nederland B.V. wwwroot Meant for static files Add static file middleware URLs for static content are relative to wwwroot Clean separation between code and static files
  47. 47. © Betabit Nederland B.V. Razor & Tag helpers
  48. 48. © Betabit Nederland B.V. DI into views @inject (adds a ‘property’ to your view Can be usefull for View-specific services (localization) Maintain a Separation of Concerns (Most of the) data your view displays should be passed in from the controller Can be used to override services Heads-up: register services you want to inject
  49. 49. © Betabit Nederland B.V. DEMO ASP.NET Core MVC
  50. 50. © Betabit Nederland B.V. ASP.NET or ASP.NET Core?
  51. 51. © Betabit Nederland B.V. Recap .NET Core Command line interface .NET Standard Entity Framework Core ASP.NET Core
  52. 52. © Betabit Nederland B.V. FINAL DEMO
  53. 53. © Betabit Nederland B.V. FX: To Core or not to Core? .NET Core .NET Framework Cross-platform needs Currently using .NET Targeting micro-services 3rd party libraries / NuGet packages Using Docker Techologies not (yet) supported High performance & scalability Side by side .NET versions
  54. 54. © Betabit Nederland B.V. What's next source: https://github.com/dotnet/core/blob/master/roadmap.md
  55. 55. © Betabit Nederland B.V. Did you know?
  56. 56. © Betabit Nederland B.V. Resources .NET Core Source Browser https://source.dot.net dotnet.exe commands http://bit.ly/nyddn-cmds Roadmap https://github.com/dotnet/core/blob/master/roadmap.md
  57. 57. © Betabit Nederland B.V.
  58. 58. Bedankt voor je aandacht © Betabit Nederland B.V.
  59. 59. © Betabit Nederland B.V.

×