Entity Framework Core Features

3y ago
18 Views
2 Downloads
2.40 MB
26 Pages
Last View : 9d ago
Last Download : 3m ago
Upload by : Julius Prosser
Transcription

Entity Framework CoreFeatures10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Topics Entity Framework .vs. EF Core Features, features, features Many code samples10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Christian Nagel Training Coaching Consulting Development Microsoft MVP www.cninnovation.com csharp.christiannagel.com10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Intro10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

CompareEntity FrameworkEntity Framework Core Long History Legacy Code Windows only Big Footprint Conventions and "Magic" Relational Databases only New Code (.NET Core 1.0) Modern Patterns Multi-Platform Smaller Footprint Conventions, no "Magic" Architecture independent ofrelational databases10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Database first, Model first notsupportedCode First –only!You still can create a model froma databasedotnet ef scaffold10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Logging .NET Core Logging ILogger, ILoggerFactory Add Query Tags (2.2) Samples: BooksSample, LazyLoading10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Connection Strings are pooled Creating context can take time DbContexts can be pooledDbContextPools (2.0) AddDbContextPool() It's just a matter of containerconfiguration No change in using the context Sample: ContextPoolSample10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Model Definition10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

ModelDefinition Convention Annotations (Attributes) Fluent API Separate configuration type withIEntityTypeConfiguration T Sample App: BooksSample10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

ShadowProperties(1.0) Are not represented in the model Available in database tables Can be accessed using the context Example Columns IsDeleted LastUpdated TenantId Sample App: BooksSample10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Define a filter that is included with everyqueryModel-LevelQuery Filter Example: IsDeleted, TenantId Sample App: BooksSample10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Mapping toFields (1.1) Read-only Properties in the modelPrivate fieldsNot accessible via PropertiesConstructors with parameters (2.1) Sample App: BooksSample10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Manage the database from code Add migrations for every change Includes seeding of dataMigrations Migrate: context.Database.Migrate() dotnet ef database update dotnet ef migrations script Sample App: MigrationsConsoleApp,MigrationsLib10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Relations10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Table perHierarchy(TPH) Inheritance One table per hierarchy Conventions Base classes and derived classes All types DbSet T mapped Fluent API Only abstract base class DbSet T mapped HasDiscriminator HasValue Sample: TPHWithConventions /TPHWithFluentAPI10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Multiple types access the same tableTable Splitting(2.0) Menu & MenuDetail types in one table Fluent API HasOne().WithOne().HasForeignKey() Sample: TableSplitting10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Owned Entities(2.0) Owned entities are part of the owner Owned attribute (2.1) Fluent API OwnsOne – define relation Sample: OwnedEntities10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

References Eager Loading Include relations with a query Include() / ThenInclude() Explicit Loading Load relations on request EntityEntry.Reference().Load EntityEntry.Collection().Load Lazy Loading (2.2) Load on property access10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

This feature needs to be explicitly enabledLazy Loading(2.2) NuGet PackageMicrosoft.EntityFrameworkCore.Proxies UseLazyLoadingProxies() with options Virtual Properties are required in the model Sample: LazyLoading10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

NoSQL10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

NoSQL Document DatabaseAzure CosmosDBSupported by EF Core 3.0Use one or multiple containers forentitiesCreate hierarchies of data in one JSONdocument: OwnsOne / OwnsMany10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

For Action EF Core is multi-platform with modern patterns Relational and No-SQL providers Source code: https://github.com/christiannagel/ThriveConf2019 Blog: https://csharp.christiannagel.com10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Questions?10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

THANK YOU10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Thank you Sponsors#ThriveITconfSilverEvening event sponsorMaterialMedia10TH ANNUAL CONFERENCE ABOUT MODERN IT TECHNOLOGIES

Entity Framework Long History Legacy Code Windows only Big Footprint Conventions and "Magic" Relational Databases only Entity Framework Core New Code (.NET Core 1.0) Modern Patterns Multi-Platform Smaller Footprint Conventions, no "Magic" Architecture independent of relational databases

Related Documents:

Entity Framework, referred to as Entity Framework 4. The completely revised second edition of Programming Entity Framework was dedicated to teaching readers how to use this version of Entity Framework in Visual Studio 2010. When .NET 4 was released, the Entity Framework team was already hard at work on a new addition, called Code First, to .

1 IV. Entity Relationship Modeling 2 Entity-Relationship Model (ERM) Basis of an Entity-Relationship Diagram (ERD) A design technique Diagrams entities sets (with attributes) and the relationship between the entity sets. Recall previous definitions Entityrefers to the entity set and not a single entity occurrence E-R diagrams are the deliverablesof the

Was ist Entity Framework? 7 Kapitel 2: .t4-Vorlagen im Entity-Framework 9 Examples 9 Schnittstellen dynamisch zum Modell hinzufügen 9 XML-Dokumentation zu Entitätsklassen hinzufügen 9 Kapitel 3: Best Practices für das Entity Framework (einfach und professionell) 11 Einführung 11 Examples 11 1- Entity Framework @ Data Layer (Grundlagen) 11

Entity Framework Entity Notes for Professionals Framework Notes for Professionals GoalKicker.com Free Programming Books Disclaimer This is an uno cial free book created for educational purposes and is not a liated with o cial Entity Framework group(s) or company(s). All trademarks and registered trademarks are the property of their respective .

Entity Framework Entity Notes for Professionals Framework Notes for Professionals GoalKicker.com Free Programming Books Disclaimer This is an uno cial free book created for educational purposes and is not a liated with o cial Entity Framework group(s) or company(s). All trademarks and registered trademarks are the property of their respective .

Entity User Experience 5. JustGrants User: Highlights. Key Takeaways In addition to the introduction of six foundational roles, JustGrants introduces increased visibility among users within the entity – the Entity User and their Entity Profile – allowing for more efficient user management. One Email Address One User One Entity.

Entity Management 23. 2) Select the Manage Users button in the . Doing Business As . section to open the My Apps screen for access to entity management in the Secure User Management system, DIAMD. Entity Users can only be managed by the Entity Admin. 2. Manage Users. Entity Management: Step 2

Created and organised by The Interface Mechanical Civil ‘Thou’ (μm) 1/16 (mm) EN 13001-02 Regular, Variable, & Occasional Loads