Download presentation
Presentation is loading. Please wait.
Published byEric Banks Modified over 6 years ago
1
A Tour of EF Core’s Most Interesting & Important Features
Julie Lerman @julielerman about.me/julielerman
2
“Entity Framework (EF) Core is a lightweight and extensible version of the popular Entity Framework data access technology.” EF Core Documentation
3
EF 6.x EF Core
4
github.com/aspnet/entityframework
docs.efproject.net
5
Modern Software Practices
.NET Core Themes Composable APIs Cross-Platform Modern Software Practices
6
Highlights of EF Core Began life as “EF7” 1.0 RTM June 27, 2016 Lightweight, Composable version of EF Performance, generated SQL, runtime model building & etc More flexible logging (ILoggerProvider) Integrates with ASP.NET Core Windows, X-Plat with .NET Core, UWP, Xamarin Lots of new features
7
Coming from EF6? Not replacing, nor an update to, EF6.x Total re-write, not backwards compatible Drops EDMX, ObjectContext Many familiar APIs: DbContext, Change Tracker, Migrations, LINQ
8
have to re-learn everything
You do not have to re-learn everything
9
But… it’s still new & different
10
COMMON INFRASTRUCTURE
9/9/2018 1:37 AM Unified platform .NET FRAMEWORK WINDOWS APPLICATIONS .NET CORE CROSS-PLATFORM SERVICES MOBILE APPLICATIONS XAMARIN TOOLS Visual Studio Visual Studio Code .NET STANDARD LIBRARY COMMON INFRASTRUCTURE Xamarin Studio Compilers Languages Runtime components EF6.x EF Core © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
11
Where Can You Use EF Core?
.NET .NET Core UWP Windows Windows, macOS, Linux Windows 10 OS Any .NET Console WinForms WPF ASP.NET 4 etc.. ASP.NET Core Web Apps & APIs Libraries Services Console Apps Mobile PC HoloLens Xbox Surface Hub IoT Devices App Types EF Core runs in .NET core and .NET core runs in a LOT of places! Inside of the full .NET Framework (that is any version from and newer, or on the more limited .NET Core which is the runtime that can run natively not only on windows but also on Mac and linux and also on another limited version of .NET which is the Universal Windows Platform for Windows 10. That doesn’t necessarily mean that you *should* use EF core in all of these scenarios. And this is a really important point
12
EF6 Features vs EF Core Features
New EF Core 1.0.0 EF Core >1.1.0 EF6 Feature Set EF Core 1.1.0 Limited Parity EF Core 1.0.0 Never coming to EF Core
13
bit.ly/efcoreroadmap Implemented (1.0) In Progress (1.1) Backlog
”EF6.x continues to be the best version of EF for a number of applications until these features are implemented” Implemented (1.0) In Progress (1.1) Backlog Critical O/RM The things we think we need before we say EF Core is the recommended version of EF. High priority features Many features on our backlog High priority but we think EF Core would be a compelling release for the vast majority of applications without them
14
EF Core 1.1 (Preview is Here! RTM Late Q4 2016)
Bug fixing to improve stability Critical O/RM features Removing adoption blockers Improved LINQ translation DbSet.Find Explicit Loading More EntityEntry APIs: Reload, GetModifiedProperties, GetDatabaseValues etc. Connection resiliency Parity with EF6.x Mapping to fields for scalar properties* SQL Server memory-optimized table support Simplified service replacement New Capabilities
15
EF Core Enables Long-Requested Features
Batch Insert, Update, Delete Unique Constraints Smarter Queries Smarter Disconnected Patterns In-Memory Provider for Testing Extensible & IoC Friendly Model-Only Properties (“Shadow State”) Smarter & Simpler Mapping But these changes will enable EF to solve problems that we’ve been asking of EF for a long time. The existing code base hindered the EF team from achieving many of these features but some are already in the 1.0 version of EF Core and more have been added to upcoming releases and even more are planned for future releases of EF Core. Some examples of features that we’ve already gained with EF Core are the ability to [CLICK] do batch insert, updates and deletes – something that has never been supported in EF although some community members have created extensions to give us that behavior in the meantime. [CLICK]We’ll can specify unique foreign keys in entities …another feature that we’ve been asking for since the first version. [CLICK]LINQ queries have become smarter ..one way EF Core enables this is to allow providers to pick and choose which parts of a query will get convereted to TSQL and which will be executed in memory. This allows us to use inline functions in our queries and also to compose LINQ methods on top of raw sql and the composed query be fully executed on the server. [CLICK] Disconnecte entities and graphs have always been troublesome. The team has created patterns to make it easier to work with entities and graphs in disconnected apps as well as to provide consistent behavior. [CLICK]Thanks to the new flexibility for providers, the team was able to create an in-memory provider that makes it really easy to build automated tests against EF code that don’t need to hit the database. This remains one of my favorite features! [CLICK]We’ve also asked Microsoft to make Entity framework more extensible and EF Core is designed to be easy to use Inversion of Control patterns and dependency injection and it integrates with ASPNET Core’s service provider functionality. [CLICK]. A source of frustration for many developers was that we could not completely hide a property in domain classes because EF could not materialize fields, only properties. EF Core is now able to populate backing fields. This is another new feature that I’m particularly fond of! [CLICK] Among improvements to EF’s mapping are capabilities such as smarter and simpler ways to create one to one and to express relationships. If you go to data.uservoice.com, focusing on the entityframework requests you can see that many of the points I just highlighted have been on the list for a long time. You can also see notes that work has been started or is being planned to attack these long requested features. In later modules of this course, I’ll show you examples of these features in action. EF Core 1.1 Mapping to Backing Fields Opt out of DB Transactions at SaveChanges Temporary Properties for run time, not DB Simple Service Replacement
16
Next After EF Core 1.1 Parity with EF6.x New Capabilities
Complex/value types Visual Studio wizard for reverse engineering Mapping to fields for navigation properties Simple type conversions New Capabilities
17
Composable is not just about Nuget packages
EF is made up of 100’s of services Service i.e. class that has a single responsibility Detecting changes to an object since it was pulled from the database Taking a particular part of a linq query and translating it to sql Reuse a piece of EF Rowan uses type mapper as an example: var mapper=_context.GetService<IRelationalTypeMapper> Replace/tweak a piece of EF (1.1) protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .ReplaceService<IModelCustomizer, CustomModelCustomizer>() .UseInMemoryDatabase();
18
My Picks To Share Change Tracker Familiar/Different In Memory Provider
Migrations Enhancements Cross- Platform via .NET Core Logging Seed from JSON ASP.NET Core Integration Demos of field mapping, use EF services directly, replacing services, SQL Server Memory optimized table in Rowan M OnDotNet Demos of improved SQL generation, performance improvements,, targeting multiple databases in Rowan Miller Ignite video
19
Resources Demos are at Rowan Miller (EF Program Mgr) - Entity Framework Core Rowan Miller - Access data in .NET Core 1.0 with Entity Framework Pluralsight: Play by Play : EF Core First Look (bit.ly/PS_EFCoreLook) Coming soon: Getting Started with EF Core EF Docs: docs.efproject.net EFCore: github.com/aspnet/entityframework Arthur Vickers (team) blog: blog.oneunicorn.com Roadmap: bit.ly/efcoreroadmap MSDN Mag Data Points articles: bit.ly/datapointscolumn
20
@julielerman about.me/julielerman
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.