Presentation is loading. Please wait.

Presentation is loading. Please wait.

Entity Framework Core (EF Core)

Similar presentations


Presentation on theme: "Entity Framework Core (EF Core)"— Presentation transcript:

1 Entity Framework Core (EF Core)
Marko Šarić Copyright Comminus d.o.o. | Buzinski prilaz 10 | Zagreb |

2 Copyright Comminus d.o.o.
Content What is EF CORE EF Core Database Support Entity Framework Core vs Entity Framework 6.x The Model (Database Context) Querying data Saving data Stored procedures Copyright Comminus d.o.o.

3 Copyright Comminus d.o.o.
How to use? .NET Core has reached the 1.1 release. It's cross-platform, open source, and wicked fast. Plus you can code on your Mac. Copyright Comminus d.o.o.

4 Copyright Comminus d.o.o.
What is EF Core Object-relational mapper (O/RM) that enables .NET developers to work with a database using .NET objects. It eliminates the need for most of the data-access code that developers usually need to write. Lightweight, extensible, and cross-platform version of Entity Framework. Built over a completely new set of core components. EF Core doesn't automatically inherit all the features from EF6.x. Some of these features will show up in future releases (such as lazy loading and connection resiliency) Less commonly used features will not be implemented in EF Core. Copyright Comminus d.o.o.

5 Copyright Comminus d.o.o.
Microsoft SQL Server (including SQL Azure) Also support for SQL Server Compact Edition Memory-Optimized Table support was introduced in EF Core SQLite PostgreSQL MySQL Built-in in-memory database (designed for testing purposes only) The Oracle .NET team is evaluating EF Core support, but have not announced any timing Database providers are installed through NuGet PM> Install-Package Microsoft.EntityFrameworkCore.SqlServer PM> Install-Package Npgsql.EntityFrameworkCore.PostgreSQL Copyright Comminus d.o.o.

6 Copyright Comminus d.o.o.
Features not in EF Core Spatial data types such as SQL Server's geography & geometry Graphical visualisation of model Loading related data: Lazy Stored procedure mapping (stored procedures are supported) Copyright Comminus d.o.o.

7 The Model A model is made up of entity classes and a derived context that represents a session with the database, allowing you to query and save data.

8 Querying Instances of your entity classes are retrieved from the database using Language Integrated Query (LINQ)

9 Querying Loading Related Data
• Eager loading: related data is loaded from the database as part of the initial query • Explicit loading: related data is explicitly loaded from the database at a later time

10 Saving data Data is created, deleted, and modified in the database using instances of your entity classes

11

12 Copyright Comminus d.o.o.
Stored Procedures Use FromSql method which executes RAW SQL queries. Limitations (and misconceptions): SQL queries can only be used to return entity types that are part of your model. Therefore, it cannot contain related data The SQL query must return data for all the properties of the entity. So basically your SQL query should be Select * from {tableName} The column names in the result set must match the column names that properties are mapped to For INSERT, UPDATE, DELETE queries: ExecuteSqlCommand. It returns integer value which indicates the count of affected rows ExecuteSqlCommand should be used on context.Database Copyright Comminus d.o.o.

13

14 Copyright Comminus d.o.o.
References Official Technical Documentation 101 LINQ Samples EF Core 1.0: First Look LINQ Fundamentals with C# 6.0 Building a Web App with ASP.NET Core, MVC 6, EF Core, and Angular app/ Copyright Comminus d.o.o.

15 Copyright Comminus d.o.o.
Copyright Comminus d.o.o.

16 Copyright Comminus d.o.o.
Hvala na pozornosti Copyright Comminus d.o.o.


Download ppt "Entity Framework Core (EF Core)"

Similar presentations


Ads by Google