SlideShare ist ein Scribd-Unternehmen logo
1 von 22
12 e 13 de abril de 2019
São Paulo, Brasil
Conectando Pessoas,
Processos e Tecnologia
#MVPConf
Trilha .NET
Deep-Dive on EntityFramework Core 2.2/3.0
Rafael Almeida
Microsoft MVP
#MVPConf
YouTube.com/codereadybr
LinkedIn.com/in/ralmsdeveloper
Twitter.com /ralmsdeveloper
Github.com/ralmsdeveloper
Rafael Almeida
Microsoft MVP, MCC & MCP
Arquiteto de Sistemas at STONE
Casado e pai de três princesas, as mais lindas!
Victória, Maria Heloysa e Maria Eduarda
Criador/Mantenedor EFCore.FirebirdSQL
Contribuidor projetos Github (Microsoft Open Source)
EntityFramework Core e EntityFramework Core for Oracle (Microsoft)
.ralms.net
Doação para Entidades
#MVPConf
Toda a renda obtida com a venda dos ingressos
para o MVPConf LATAM 2019 serão doados para
cinco Entidades beneficentes.
Uma em cada região do Brasil!
Consulte no site as Entidades beneficiadas!
MVPConf.com.br
Patrocinadores
#MVPConf
#MVPConf
Agenda
The
.NETCore
.NET
Foundation
Jornada
Open
Source
Aquisições EF Core 2.1 EFCore 2.2 EF Core 3.0 Demos
#MVPConf
DESKTOP WEB CLOUD MOBILE GAMING IoT AI
.NETCore
Your platform for building anything
.NET
ECOSYSTEM
macOSiOS
ASP.NET SignalR
.NET SDK for Hadoop
.NET Compiler Platform ("Roslyn")
.NET Micro Framework
ASP.NET MVC
ASP.NET Web API
ASP.NET Web Pages
MVVM Light Toolkit
.NET Core
Orleans
MEF
OWIN Authentication Middleware
Orchard CMS
Microsoft Azure SDK for .NET
IdentityManager
Mimekit
Xamarin.Auth
Couchbase Lite for .NET
Mailkit
ASP.NET Core
Salesforce Toolkits for .NET
NuGet
Kudu
Cecil
MSBuild
LLILC
Prism
WorldWide Telescope
ASP.NET AJAX Control Toolkit
Entity Framework
Microsoft Azure WebJobs SDK
Microsoft Web Protection Library
Open Live Writer
Open XML SDK
ProtoBuild
System.Drawing
IdentityServer
Umbraco
WCF
Xamarin.Mobile
Mono
Xamarin SDK
Cake
Steeltoe
Nancy
xUnit
DotNetNuke
SourceLink
nUnit
MvvmCross
IronPython
ILMerge
ML.NET
Infer.NET
JSON.NET
#MVPConf
.NET
2001
ECMA 335
2002
NET 1.0 for
Windows released.
Mono project
begins
2008
ASP.NET MVC
(web platform)
open source
April 2014
.NET Compiler
Platform (“Roslyn”)
open source
.NET Foundation
founded
Nov. 2014
.NET Core
(cross-platform)
project begins
2016
Mono project joins
.NET Foundation
Aug. 2017
.NET Core 2.0
released
June 2018
.NET Core 2.1
released
#MVPConf
Example: StringBuilder
private static readonly StringBuilder s_builder = new StringBuilder();
public void StringBuilderAppend()
{
StringBuilder sb = s_builder;
sb.Length = 0;
for (int i = 0; i < 100_000; i++)
sb.Append(i);
}
Toolchain Mean Allocated
.NET Core 2.0 6.523 ms 3992000 B
.NET Core 2.1 3.268 ms 0 B
#MVPConf
Example: Strings
public string StringToLowerChangesNeeded() =>
"This is a test to see what happens when we call ToLower.".ToLower();
public string StringToLowerAlreadyCased() =>
"this is a test to see what happens when we call tolower.".ToLower();
Method Toolchain Mean Allocated
StringToLowerChangesNeeded .NET Core 2.0 187.00 ns 144 B
StringToLowerChangesNeeded .NET Core 2.1 96.29 ns 144 B
StringToLowerAlreadyCased .NET Core 2.0 197.21 ns 144 B
StringToLowerAlreadyCased .NET Core 2.1 68.81 ns 0 B
#MVPConf
Engenheiros do EFCore
#MVPConf
EF Core 2.1 Major Features
#MVPConf
EF Core 2.2 Major Features
#MVPConf
Configurations
Como funcionava até 2.1?
http://ralms.net/dica/dicaapplyconfiguration/
#MVPConf
Exemplo
public class SampleDbContext : DbContext
{
public SampleDbContext(DbContextOptions<SampleDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new LoginConfiguration());
modelBuilder.ApplyConfiguration(new ClienteConfiguration());
modelBuilder.ApplyConfiguration(new EnderecoConfiguration());
modelBuilder.ApplyConfiguration(new CidadeConfiguration());
modelBuilder.ApplyConfiguration(new ProdutoConfiguration());
modelBuilder.ApplyConfiguration(new EstoqueConfiguration());
modelBuilder.ApplyConfiguration(new ...);
}
}
#MVPConf
Chuck Norris
var mappingTypes = assembly
.GetTypes()
.Where(x =>
!x.IsAbstract
&& x.GetInterfaces()
.Any(y =>
y.GetTypeInfo().IsGenericType
&& y.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>)));
var entityMethod = typeof(ModelBuilder).GetMethods()
.Single(x => x.Name == "Entity" &&
x.IsGenericMethod &&
x.ReturnType.Name == "EntityTypeBuilder`1");
foreach (var mappingType in mappingTypes)
{
var genericTypeArg = mappingType.GetInterfaces().Single().GenericTypeArguments.Single();
var genericEntityMethod = entityMethod.MakeGenericMethod(genericTypeArg);
var entityBuilder = genericEntityMethod.Invoke(modelBuilder, null);
var mapper = Activator.CreateInstance(mappingType);
mapper.GetType().GetMethod("Configure").Invoke(mapper, new[] { entityBuilder });
}
#MVPConf
Solução tabajara, perfeita!
public class SampleDbContext : DbContext
{
public SampleDbContext(DbContextOptions<SampleDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
var assembly = typeof(SampleDbContext).Assembly;
modelBuilder.ApplyConfigurationsFromAssembly(assembly);
}
}
#MVPConf
Hint’s SQL
With NOLOCK
Sorteios dos Brindes
#MVPConf
Clique Aqui para Iniciar o Sorteio
Somente participarão dos sorteios os
participantes que estiverem inscritos
nas palestras e responderem as
pesquisas de satisfação.
OBRIGADO
#MVPConf
YouTube.com/codereadybr
LinkedIn.com/in/ralmsdeveloper
Twitter.com /ralmsdeveloper
Github.com/ralmsdeveloper
.ralms.net
THANKS!

Weitere ähnliche Inhalte

Ähnlich wie EF Core Deep-Dive 2.2/3.0 Features

Certified Core Java Developer
Certified Core Java DeveloperCertified Core Java Developer
Certified Core Java DeveloperNarender Rana
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerCisco Canada
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government DevelopersFrank La Vigne
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java CertificationVskills
 
MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)Peter Presnell
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsRobert MacLean
 
The future for Software developers by 2040
The future for Software developers by 2040The future for Software developers by 2040
The future for Software developers by 2040Venkatarangan Thirumalai
 
Daniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days OcDaniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days OcDaniel Egan
 
Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Tzach Zohar
 
powershell-is-dead-epic-learnings-london
powershell-is-dead-epic-learnings-londonpowershell-is-dead-epic-learnings-london
powershell-is-dead-epic-learnings-londonnettitude_labs
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure FunctionsMassimo Bonanni
 
Donetconf2016: The Future of C#
Donetconf2016: The Future of C#Donetconf2016: The Future of C#
Donetconf2016: The Future of C#Jacinto Limjap
 
支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒Toki Kanno
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009nkaluva
 
#CNX14 - Building Killer Apps - Moving Beyond Transactions to Experiences
#CNX14 - Building Killer Apps - Moving Beyond Transactions to Experiences#CNX14 - Building Killer Apps - Moving Beyond Transactions to Experiences
#CNX14 - Building Killer Apps - Moving Beyond Transactions to ExperiencesSalesforce Marketing Cloud
 
Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...
Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...
Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...Priyanka Aash
 
Netw 208 Success Begins / snaptutorial.com
Netw 208  Success Begins / snaptutorial.comNetw 208  Success Begins / snaptutorial.com
Netw 208 Success Begins / snaptutorial.comWilliamsTaylor65
 
Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Massimo Bonanni
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan
 

Ähnlich wie EF Core Deep-Dive 2.2/3.0 Features (20)

Certified Core Java Developer
Certified Core Java DeveloperCertified Core Java Developer
Certified Core Java Developer
 
Novidades do c# 7 e 8
Novidades do c# 7 e 8Novidades do c# 7 e 8
Novidades do c# 7 e 8
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data center
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
 
MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 Enhancements
 
The future for Software developers by 2040
The future for Software developers by 2040The future for Software developers by 2040
The future for Software developers by 2040
 
Daniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days OcDaniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days Oc
 
Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)
 
powershell-is-dead-epic-learnings-london
powershell-is-dead-epic-learnings-londonpowershell-is-dead-epic-learnings-london
powershell-is-dead-epic-learnings-london
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure Functions
 
Donetconf2016: The Future of C#
Donetconf2016: The Future of C#Donetconf2016: The Future of C#
Donetconf2016: The Future of C#
 
支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒支撐英雄聯盟戰績網的那條巨蟒
支撐英雄聯盟戰績網的那條巨蟒
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009
 
#CNX14 - Building Killer Apps - Moving Beyond Transactions to Experiences
#CNX14 - Building Killer Apps - Moving Beyond Transactions to Experiences#CNX14 - Building Killer Apps - Moving Beyond Transactions to Experiences
#CNX14 - Building Killer Apps - Moving Beyond Transactions to Experiences
 
Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...
Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...
Transfer Learning: Repurposing ML Algorithms from Different Domains to Cloud ...
 
Netw 208 Success Begins / snaptutorial.com
Netw 208  Success Begins / snaptutorial.comNetw 208  Success Begins / snaptutorial.com
Netw 208 Success Begins / snaptutorial.com
 
Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 

Kürzlich hochgeladen

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 

Kürzlich hochgeladen (20)

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 

EF Core Deep-Dive 2.2/3.0 Features

  • 1. 12 e 13 de abril de 2019 São Paulo, Brasil Conectando Pessoas, Processos e Tecnologia
  • 2. #MVPConf Trilha .NET Deep-Dive on EntityFramework Core 2.2/3.0 Rafael Almeida Microsoft MVP
  • 3. #MVPConf YouTube.com/codereadybr LinkedIn.com/in/ralmsdeveloper Twitter.com /ralmsdeveloper Github.com/ralmsdeveloper Rafael Almeida Microsoft MVP, MCC & MCP Arquiteto de Sistemas at STONE Casado e pai de três princesas, as mais lindas! Victória, Maria Heloysa e Maria Eduarda Criador/Mantenedor EFCore.FirebirdSQL Contribuidor projetos Github (Microsoft Open Source) EntityFramework Core e EntityFramework Core for Oracle (Microsoft) .ralms.net
  • 4. Doação para Entidades #MVPConf Toda a renda obtida com a venda dos ingressos para o MVPConf LATAM 2019 serão doados para cinco Entidades beneficentes. Uma em cada região do Brasil! Consulte no site as Entidades beneficiadas! MVPConf.com.br
  • 8. #MVPConf DESKTOP WEB CLOUD MOBILE GAMING IoT AI .NETCore Your platform for building anything
  • 9. .NET ECOSYSTEM macOSiOS ASP.NET SignalR .NET SDK for Hadoop .NET Compiler Platform ("Roslyn") .NET Micro Framework ASP.NET MVC ASP.NET Web API ASP.NET Web Pages MVVM Light Toolkit .NET Core Orleans MEF OWIN Authentication Middleware Orchard CMS Microsoft Azure SDK for .NET IdentityManager Mimekit Xamarin.Auth Couchbase Lite for .NET Mailkit ASP.NET Core Salesforce Toolkits for .NET NuGet Kudu Cecil MSBuild LLILC Prism WorldWide Telescope ASP.NET AJAX Control Toolkit Entity Framework Microsoft Azure WebJobs SDK Microsoft Web Protection Library Open Live Writer Open XML SDK ProtoBuild System.Drawing IdentityServer Umbraco WCF Xamarin.Mobile Mono Xamarin SDK Cake Steeltoe Nancy xUnit DotNetNuke SourceLink nUnit MvvmCross IronPython ILMerge ML.NET Infer.NET JSON.NET
  • 10. #MVPConf .NET 2001 ECMA 335 2002 NET 1.0 for Windows released. Mono project begins 2008 ASP.NET MVC (web platform) open source April 2014 .NET Compiler Platform (“Roslyn”) open source .NET Foundation founded Nov. 2014 .NET Core (cross-platform) project begins 2016 Mono project joins .NET Foundation Aug. 2017 .NET Core 2.0 released June 2018 .NET Core 2.1 released
  • 11. #MVPConf Example: StringBuilder private static readonly StringBuilder s_builder = new StringBuilder(); public void StringBuilderAppend() { StringBuilder sb = s_builder; sb.Length = 0; for (int i = 0; i < 100_000; i++) sb.Append(i); } Toolchain Mean Allocated .NET Core 2.0 6.523 ms 3992000 B .NET Core 2.1 3.268 ms 0 B
  • 12. #MVPConf Example: Strings public string StringToLowerChangesNeeded() => "This is a test to see what happens when we call ToLower.".ToLower(); public string StringToLowerAlreadyCased() => "this is a test to see what happens when we call tolower.".ToLower(); Method Toolchain Mean Allocated StringToLowerChangesNeeded .NET Core 2.0 187.00 ns 144 B StringToLowerChangesNeeded .NET Core 2.1 96.29 ns 144 B StringToLowerAlreadyCased .NET Core 2.0 197.21 ns 144 B StringToLowerAlreadyCased .NET Core 2.1 68.81 ns 0 B
  • 14. #MVPConf EF Core 2.1 Major Features
  • 15. #MVPConf EF Core 2.2 Major Features
  • 16. #MVPConf Configurations Como funcionava até 2.1? http://ralms.net/dica/dicaapplyconfiguration/
  • 17. #MVPConf Exemplo public class SampleDbContext : DbContext { public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration(new LoginConfiguration()); modelBuilder.ApplyConfiguration(new ClienteConfiguration()); modelBuilder.ApplyConfiguration(new EnderecoConfiguration()); modelBuilder.ApplyConfiguration(new CidadeConfiguration()); modelBuilder.ApplyConfiguration(new ProdutoConfiguration()); modelBuilder.ApplyConfiguration(new EstoqueConfiguration()); modelBuilder.ApplyConfiguration(new ...); } }
  • 18. #MVPConf Chuck Norris var mappingTypes = assembly .GetTypes() .Where(x => !x.IsAbstract && x.GetInterfaces() .Any(y => y.GetTypeInfo().IsGenericType && y.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))); var entityMethod = typeof(ModelBuilder).GetMethods() .Single(x => x.Name == "Entity" && x.IsGenericMethod && x.ReturnType.Name == "EntityTypeBuilder`1"); foreach (var mappingType in mappingTypes) { var genericTypeArg = mappingType.GetInterfaces().Single().GenericTypeArguments.Single(); var genericEntityMethod = entityMethod.MakeGenericMethod(genericTypeArg); var entityBuilder = genericEntityMethod.Invoke(modelBuilder, null); var mapper = Activator.CreateInstance(mappingType); mapper.GetType().GetMethod("Configure").Invoke(mapper, new[] { entityBuilder }); }
  • 19. #MVPConf Solução tabajara, perfeita! public class SampleDbContext : DbContext { public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { var assembly = typeof(SampleDbContext).Assembly; modelBuilder.ApplyConfigurationsFromAssembly(assembly); } }
  • 21. Sorteios dos Brindes #MVPConf Clique Aqui para Iniciar o Sorteio Somente participarão dos sorteios os participantes que estiverem inscritos nas palestras e responderem as pesquisas de satisfação.