entity framework for cross platform apps

19
EF For Cross Platform Apps @svswaminathan BDotNet UG Meet, Aug 2016

Upload: svswaminathan

Post on 22-Jan-2018

1.313 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Entity Framework for Cross platform apps

EF For Cross Platform Apps@svswaminathan

BDotNet UG Meet, Aug 2016

Page 2: Entity Framework for Cross platform apps

Swaminathan Vetri

• Senior Engineer @ Target

• Microsoft MVP - Visual Studio & Development technologies

• Windows/Web/Cross platform mobile developer

• Blogger, Speaker, Amateur photographer, Gadget freak

2

Page 3: Entity Framework for Cross platform apps

Objective

• What is EF Core ?

• Why EF Core ?

• What it offers ?

• EF Core vs EF 6.x

• Demos

Page 4: Entity Framework for Cross platform apps

What is EF Core ?

• Entity Framework (EF) Core is an object-relational mapper (O/RM) that enables .NET developers to work with a database using .NET objects.

• EF Core is a lightweight and extensible version of the popular Entity Framework data access technology.

Page 5: Entity Framework for Cross platform apps

Why EF Core ?

• Cross platform i.e., EF Core works on Windows/Mac/Linux

• Lightweight and Composable

• Supports new data stores (relational & non-relational)

• Multiple Database providers

• Optimized around being a simple intuitive O/RM

Page 6: Entity Framework for Cross platform apps

What it offers?

• Modelling

• Change Tracking

• SaveChanges

• Querying

• Database Schema Management

• Database Providers

• Platforms

Page 7: Entity Framework for Cross platform apps

Modelling

• Basic modelling• Built in conventions• Fluent API• Data Annotations• Relationships• Shadow state properties• Model validation• Key Value generation• Relational : Table mapping• TPH inheritance

Page 8: Entity Framework for Cross platform apps

Change Tracking

• Snapshot change tracking

• Notification change tracking

• Accessing tracked state • Via DbContext.Entry/DbContext.ChangeTracker

• Attaching detached entities/graphs • Via DbContext.AttachGraph API

Page 9: Entity Framework for Cross platform apps

Save Changes

• Basic Save

• Optimistic Concurrency

• Async Save changes

• Transactions

• Relational : Batching of statements

Page 10: Entity Framework for Cross platform apps

Querying

• LINQ Support

• Mixed client/server evaluation

• NoTracking

• Eager loading

• Async Query

• Raw SQL Queries• Via DbSet.FromSql

Page 11: Entity Framework for Cross platform apps

Database Schema Management

• Database Creation/Deletion

• Relational Database migration

• Reverse Engineer from Database

Page 12: Entity Framework for Cross platform apps

Database Providers

• Microsoft SqlServer – connects to SQL server 2008 onwards

• Microsoft SqlServer Compact edition

• IBM data servers

• Sqlite

• InMemory

• Postgres

• MySQL, Oracle (Coming soon)

Page 13: Entity Framework for Cross platform apps

Platforms

• Full .Net• Console, WPF, WinForms, ASP.NET 4

• .Net Core• Asp.Net Core on Windows, Linux and OS X

• UWP

Page 14: Entity Framework for Cross platform apps

EF Core vs EF 6.x

Page 15: Entity Framework for Cross platform apps

What’s new in EF Core ?

• Support for UWP, Asp.Net Core, Xamarin (coming soon)

• Database providers like InMemory, Azure Table storage, Redis etc.,

• Reverse engineer model from command line (Scaffold-DbContext)

• Shadow state properties

• Alternate Keys, Key generation at Client

• Mixed client/server evaluation

• Batching of statements (only relational)

Page 16: Entity Framework for Cross platform apps

What’s NOT available in EF Core ?

• Inheritance (Table per type, Table per concrete class)

• Many to many without join entities

• Complex/value types, Spatial data, graphical visualization of model, Drag and drop editor, EDMX

• Reverse engineer from database (VS Wizard), Incremental model update from DB

• Lazy loading, explicit loading, Stored Procedure

• Seed data, Connection resiliency, lifecycle hooks (events, command interception etc.,)

Page 17: Entity Framework for Cross platform apps

Demo

Page 18: Entity Framework for Cross platform apps

Useful links

• https://github.com/aspnet/EntityFramework/wiki/Roadmap

• https://github.com/aspnet/EntityFramework/wiki/Guiding-Principles

• https://docs.efproject.net/en/latest/intro.html

• https://docs.efproject.net/en/latest/efcore-vs-ef6/features.html#side-by-side-comparison

Page 19: Entity Framework for Cross platform apps

Thank YouQuestions/Feedbacks : [email protected] | @svswaminathan