Data Access in .NET Core 3.0 Applications

Slides:



Advertisements
Similar presentations
Web & Cloud Development Jason Keicher - Microsoft.
Advertisements

ISYS 512 Business Application Design and Development with.Net David Chao.
Ronnie Saurenmann Principal Architect Microsoft Switzerland.
Windows Forms in Visual Studio 2005 Mike Pelton Systems Engineer Microsoft Ltd
Entity Framework 7 Who Are You & What Have You Done to my ORM?
Entity Framework 7: What’s New? Ricardo Peres Technical Evangelist at Simplifydigital. Microsoft
Data Access Methodologies: When to choose what (ADO.NET, Entity Framework, WCF Data Services) Wriju Ghosh Lead Partner Consultant, Microsoft.
What is it all about? .NET MeetUp in Prague, CZ (2017/7/19)
Top 10 Entity Framework Features Every Developer Should Know
DevOps with ASP.NET Core and Entity Framework Core
Introducing the Microsoft® .NET Framework
Unleash .NET 2015 in your apps
Introduction to ASP.NET Core
Getting started with .NET Core
Accelerate your DevOps with OpenShift by Red Hat
5/15/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
5/15/2018 5:43 PM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
What’s new in Entity Framework Core 2.0
Mobile App Trends: lifecycle, functions, and cognitive
ASP.NET Core: Web apps, cloud apps, and containers
6/2/2018 4:08 AM BRK3327 Ten things you didn't know about building .NET UWP apps in Visual Studio 2017 Daniel Jacobson Program Manager – Visual Studio.
The Modern ASP.NET Tech Stack!
 .NET CORE
Visual Studio Tools for Office 2005
Did your feature got in, out or planned?
Building Innovative Apps using the Microsoft Developer Platform
SQL Server Data Tools for Visual Studio Part I: Core SQL Server Tools
Entity Framework By: Casey Griffin.
ASP.NET in Linux and Windows containers
A Tour of EF Core’s Most Interesting & Important Features
Microsoft Build /13/2018 2:24 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Entity Framework Core for Enterprise Applications
Microsoft Virtual Academy
1.1. .NET architectural components and .NET Core
Learn. Imagine. Build. .NET Conf
.NET Standard Jon Galloway | Executive Director, .NET |
ADO.NET Entity Framework
Microsoft Build /8/2018 8:41 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Explore web development with Microsoft ASP.NET Core 1.0
What is it all about? .NET MeetUp in Amsterdam, NL (2017/7/11)
ADO.NEXT Advances in Data Access for 2008
Building Modern Web Apps with ASP.NET MVC 6
Slides and images stolen from “real” .NET Conf. presenters
DotnetConf 11/14/2018 3:27 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE.
Microsoft Build /14/ :29 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Microsoft Build /15/2018 6:28 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
An Introduction to Entity Framework
Microsoft Connect /17/ :34 AM
Learn. Imagine. Build. .NET Conf
Entity Framework Core.
Microsoft Connect /1/2018 2:36 AM
12/3/2018 7:56 PM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
12/5/ :36 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
Entity Framework Core (EF Core)
MIX 09 12/8/2018 4:33 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Tech Ed North America /1/ :36 AM Required Slide
What’s new in ASP.NET Core and Entity Framework 2.2 (Preview 3)
From Development to Production: Optimizing for Continuous Delivery
.NET Conf 2018 Keynote Jose Barbosa Aaron Amm Theeranit.
TechEd /3/ :48 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Best practices for packaging and distributing device drivers
From Development to Production: Optimizing for Continuous Delivery
Implementing Entity Framework with MVC Jump Start
5/6/2019 7:40 PM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS.
Windows Forms in Visual Studio 2005: An in-depth look at key features
The Future is Now with ASP.NET Core 3.0
Productive + Hybrid + Intelligent + Trusted
Running C# in the browser
Blazor A new framework for browser-based .NET apps Ryan Nowak
Presentation transcript:

Data Access in .NET Core 3.0 Applications Marco Minerva Microsoft MVP Windows Development Intel Software Innovator https://about.me/marcominerva Riccardo Cappello Microsoft MVP Microsoft Azure Intel Software Innovator https://about.me/rcappello Data Access in .NET Core 3.0 Applications

.NET Core 3.0

.NET Core 3 2 WEB CLOUD DESKTOP IoT AI .NET Core 3 expands supported workloads to include Windows Desktop, IoT & AI .NET Core is perfectly suited for the requirements of cloud-native, cross-platform workloads COMPILERS LANGUAGES RUNTIME COMPONENTS LIBRARIES INFRASTRUCTURE .NET CORE 3 .NET CORE https://blogs.msdn.microsoft.com/dotnet/2018/05/07/net-core-3-and-support-for-windows-desktop-applications/ As developers, we want to ensure our code PERFORMS WELL, is PORTABLE, and is MAINTABLE. With .NET Core 3 we are bringing support to new device types including AI, IOT, and DESKTOP. .NET CORE for DESKTOP means you NO LONGER need a DEPENDENCY on the .NET FRAMEWORK installed on the machine – you ship what you need. .NET CORE has a smaller footprint and IMPROVED PERFORMANCE. .NET CORE also supports a more MODERN .csproj PROJECT SYSTEM.

.NET Core 3.0 Desktop improvements Build 2015 7/4/2019 5:39 AM .NET Core 3.0 Desktop improvements Supports for WPF and Windows Forms frameworks XAML Islands: Windows Forms & WPF can host UWP XAML Controls: Windows Forms & WPF browser and media UWP controls Improvements on HDPI support Access to all the Windows 10 API’s .NET Core App Bundler Precompiled, fast startup Small apps by removing unused dependencies, link away unused IL Single self-contained .EXE You will get to MAXIMIZE CODE RE-USE across all of these DEVICE TYPES and we will SUPPORT WINFORMS and WPF controls and XAML ISLANDS. You will have access to ALL WINDOWS 10 APIS and .NET CORE TOOLING that will bring you that IMPROVED PERFORMANCE. © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Why Windows Desktop on .NET Core? Build 2015 7/4/2019 5:39 AM Why Windows Desktop on .NET Core? Side by side execution Machine global or app local framework Core runtime and API improvements New .csproj project system http://danpatrascu.com/whats-the-point-of-net-core-3-0-desktop-applications Having desktop applications in .Net Core means that developers can take advantage of the self contained deployment of .Net Core applications so on one computer we can potentially have several such desktop applications, each running on different versions of .Net Core. From a more strategic point of view, bringing desktop applications to .Net Core 3.0 means that Microsoft continues to open source parts of their proprietary Windows centric products and APIs. This is a clear message that when Microsoft talks about the benefits of open source software, they really mean it since they bring more and more products and APIs to the open source world © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

The future of .NET Framework Build 2015 7/4/2019 5:39 AM The future of .NET Framework .NET Framework 4.8 is a 18 years old Framework Innovating without breaking anything is nearly impossible It won’t support .NET Standard 2.1 .NET Framework will be supported for years , but we don’t know if there will be another one after 4.8 New applications should be started in .NET Core https://marketplace.visualstudio.com/items?itemName=BrianLagunas.ConvertProjectToNETCore3 Extension to convert WPF applications to .NET Core 3.0 https://medium.com/@andy.watt83/the-net-framework-is-done-8aec3bbae12d © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Start experimenting with .NET Core 3.0 Build 2015 7/4/2019 5:39 AM Start experimenting with .NET Core 3.0 Install Visual Studio 2019 Preview Download the latest 3.0.x bits from https://dotnet.microsoft.com/download/dotnet-core/3.0 Create a WPF or Windows Forms application via the New Project dialog or from CLI dotnet new wpf –n <app_name> dotnet new winforms –n <app_name> No Designer support (yet) Be sure to enable the Preview .NET Core SDK © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Demo

Data Access Methodologies

System.Data.SqlClient Fully supported in .NET Standard 2.0 Build 2015 7/4/2019 5:39 AM System.Data.SqlClient Fully supported in .NET Standard 2.0 Safe to use with .NET Core 3.0 Includes the loved and hated DataSet © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Classic ADO.NET approach Build 2015 7/4/2019 5:39 AM Classic ADO.NET approach © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Entity Framework Core OR/M Re-written from scratch Build 2015 7/4/2019 5:39 AM Entity Framework Core OR/M Re-written from scratch Lightweight, extensible, cross-platform Better performance than Entity Framework Supports only a subset of Entity Framework features © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

* New in EF Core 2.2 Only in EF6 Stored procedure mapping for CUD Many-to-many TPT, TPC inheritance Entity splitting Simple logging API Change tracking proxies Interception extensibility Database-agnostic SQL dialect Visual designer Common features Spatial data* Seed data Lazy loading GroupBy translation Any type from raw SQL System.Transactions Change tracking events Compiled queries Complex/owned types Table splitting Eager loading Connection resiliency TPH inheritance Only in EF Core Cosmos DB provider* Collections of owned entities* Query tags* Reverse engineering of database views* Eager loading for derived types Non-default constructors Rich value conversions Query types (no keys) Cross-platform & .NET Standard Global query filters DbContext pooling Simple function mapping Rich diagnostics and logging Alternate keys Field mapping Shadow properties More readable SQL Client key generation Batching of statements Mixed query evaluation Disconnected graph API DI and service replacement LINQ composition over raw SQL In-memory provider (for testing) 7/4/2019 5:39 AM * New in EF Core 2.2 © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Entity Framework * roadmap 2018 Entity Framework Core 2.2 Cosmos DB provider (preview) Spatial extensions for SQL Server and SQLite Reverse engineering of database views Collection of owned entities Query tags 2019 Entity Framework Core 3.0 Improved LINQ implementation Aggregate behaviors C# 8 support: Nullable reference types Standard IAsyncEnumerable<T> interface Public code first conventions Better support for Views Property bag entities (for many-to-many relationships) Ignore parts of the model for Migrations Entity Framework 6.3 running on .NET Core 3.0 https://docs.microsoft.com/en-us/ef/core/what-is-new/roadmap https://www.infoq.com/news/2019/01/EF-Core-3.0-Roadmap Features not on the EF Core 3.0 Roadmap Stored Procedures First class support for stored procedures will not be offered in the EF Core 3.0 timeframe. Table Per Type Inheritance When tables are very wide with far too many columns, one technique to address the problem is Table Per Type inheritance. With this model, each row is identified as belonging to one of several subtypes. Each subtype gets its own table with just the columns that are unique to that subtype. Only columns that are common to all subtypes remain in the original table. Currently table per type inheritance is supported by Entity Framework, but not EF Core. Upsert Upsert, the ability to conditionally insert or update a record, is considered a second-tier ORM feature. While not necessary, it is nice to have as it can reduce round-trips to the database and simplify code. However, it currently doesn’t fit the EF Core model.

Entity Framework 6.3 on .NET Core 3.0 Cheapest way to move existing app to .NET Core EF Core 3.0 will still be recommended No new features in EF6 (but PRs are considered) Cross-platform (Windows, Linux, Mac) No spatial support for SQL Server Providers will need to port too EF Designer may require workarounds

Dapper Micro OR/M Speed Simplicity Avoiding the ceremony of ADO.NET Build 2015 7/4/2019 5:39 AM Dapper Micro OR/M Speed Simplicity Avoiding the ceremony of ADO.NET We don’t have many features of Entity Framework Lazy Loading Change Tracking … https://iamtimcorey.com/ask-tim-dont-use-entity-framework/ https://medium.com/@engr.mmohsin/entity-framework-core-2-dapper-performance-benchmark-c29e8cce9e1b Speed – OR/M means overhead, a micro OR/M performance will be very close to plain ADO.NET. In my experience, data access is very often the performance bottleneck. OR/Ms ship with a bunch of features that require some extra work that you don’t need, shouldn’t need. OR/Ms often need a significant amount of configuration and setup, especially if you don’t (or can’t) follow conventions. With a Micro OR/M it’s pretty much Install-Package and you’re ready to go. ADO.NET is (was) pretty great, but it shipped with .NET 1.0, that’s like 18 years ago In technology terms, it’s as old as the moon. There is so much ceremony with ADO.NET that it’s just intolerable in many (not all) cases © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

How it works Sits right on top of ADO.NET Build 2015 7/4/2019 5:39 AM How it works Sits right on top of ADO.NET Extension methods for IDbConnection We need to write SQL Updating legacy applications is much easier © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Data Access Architecture

N-tier architecture Presentation Layer Business Layer SqlClient Build 2015 7/4/2019 5:39 AM N-tier architecture Presentation Layer Business Layer https://it.wikipedia.org/wiki/Architettura_multi-tier SqlClient Entity Framework Dapper … Data Access Layer © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Classic (old) approach Build 2015 7/4/2019 5:39 AM Classic (old) approach Presentation Layer Business Layer On the client Data Access Layer © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Client/server approach Build 2015 7/4/2019 5:39 AM Client/server approach Presentation Layer On the client Network Business Layer Exposed as a service Data Access Layer © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Demo

References https://dotnet.microsoft.com https://github.com/dotnet/wpf https://github.com/dotnet/winforms https://docs.microsoft.com/en-us/ef/core https://github.com/StackExchange/Dapper https://www.telerik.com/products/wpf/overview.aspx https://github.com/marcominerva/SqlSat829

Thanks! Questions? DotNetToscana Dotnettoscana.org @dotnettoscana Marco Minerva - @marcominerva Microsoft MVP – Windows Development http://about.me/marcominerva Riccardo Cappello - @rcappello Microsoft MVP – Microsoft Azure http://about.me/rcappello DotNetToscana Dotnettoscana.org @dotnettoscana