SlideShare uma empresa Scribd logo
1 de 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!

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Último

Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
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
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
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
 
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
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 

Último (20)

Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
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
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
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...
 
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...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 

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.