Entity Framework Core Quick Overview

Entity Framework (EF) Core is a lightweight, extensible, and cross-platform version of the popular Entity Framework data access technology.

EF Core can serve as an object-relational mapper (O/RM), enabling .NET developers to work with a database using .NET objects, and eliminating the need for most of the data-access code they usually need to write.

EF Core supports many database engines, see Database Providers for details.

If you like to learn by writing code, we'd recommend one of our Getting Started guides to get you started with EF Core.

What is new in EF Core

If you are familiar with EF Core and want to jump straight into the details of the latest releases:

Get Entity Framework Core

Install the NuGet package for the database provider you want to use. For example, to install the SQL Server provider in cross-platform development using dotnet tool in the command line:

dotnet add package Microsoft.EntityFrameworkCore.SqlServer

Or in Visual Studio, using the Package Manager Console:

Install-Package Microsoft.EntityFrameworkCore.SqlServer

See Database Providers for information on available providers and Installing EF Core for more detailed installation steps.

The Model

With EF Core, data access is performed using a 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. See Creating a Model to learn more.

You can generate a model from an existing database, hand code a model to match your database, or use EF Migrations to create a database from your model (and evolve it as your model changes over time).

using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;

namespace Intro
    public class BloggingContext : DbContext
        public DbSet<Blog> Blogs { get; set; }
        public DbSet<Post> Posts { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

    public class Blog
        public int BlogId { get; set; }
        public string Url { get; set; }
        public int Rating { get; set; }
        public List<Post> Posts { get; set; }

    public class Post
        public int PostId { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }

        public int BlogId { get; set; }
        public Blog Blog { get; set; }


Instances of your entity classes are retrieved from the database using Language Integrated Query (LINQ). See Querying Data to learn more.

using (var db = new BloggingContext())
    var blogs = db.Blogs
        .Where(b => b.Rating > 3)
        .OrderBy(b => b.Url)

Saving Data

Data is created, deleted, and modified in the database using instances of your entity classes. See Saving Data to learn more.

using (var db = new BloggingContext())
    var blog = new Blog { Url = "http://sample.com" };