---
title: "What is EF Core?"  
description: "What is EF Core?"  
author: "Utpal Vishwas"  
published: 2025-05-20  
updated: 2025-05-20  
canonical: https://www.mindstick.com/interview/34144/what-is-ef-core  
category: "c#"  
tags: ["c#", "api(s)", "entity framework", ".net core"]  
reading_time: 4 minutes  

---

# What is EF Core?

**EF Core (Entity Framework Core)** is a **lightweight, extensible, open-source, cross-platform Object-Relational Mapper (ORM)** developed by Microsoft. It is the modern version of Entity Framework and is used to interact with relational databases using C# objects.

## Key Features of EF Core

| Feature | Description |
| --- | --- |
| **ORM** | Maps C# classes to database tables and columns. |
| **LINQ Support** | Query the database using LINQ syntax. |
| **Migrations** | Handles schema changes through code-based migrations. |
| **Cross-platform** | Works on Windows, Linux, macOS. |
| **Database Providers** | Supports SQL Server, SQLite, PostgreSQL, MySQL, Oracle, etc. |
| **Change Tracking** | Automatically tracks changes to objects for `Insert`, `Update`, or `Delete`. |

## How EF Core Works

## Define a Model (C# Classes)

```cs
public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
}
```

**Create a** `DbContext` **Class**

```cs
public class AppDbContext : DbContext
{
    public DbSet<Product> Products { get; set; }

    public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
}
```

**Configure EF Core (e.g., in** `Startup.cs` **or** `Program.cs`**)**

```cs
services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer("Your_Connection_String"));
```

## Use EF Core in Code

```cs
public class ProductService
{
    private readonly AppDbContext _context;

    public ProductService(AppDbContext context)
    {
        _context = context;
    }

    public List<Product> GetAll()
    {
        return _context.Products.ToList();
    }
}
```

## Advantages

1. No need to write SQL for most queries.
2. Keeps code DRY by centralizing models.
3. Works well with ASP.NET Core and dependency injection.
4. Supports unit testing with in-memory databases.

## EF Core vs EF 6

| Feature | EF 6 | EF Core |
| --- | --- | --- |
| Platform | .NET Framework only | .NET Core & .NET 5+ |
| Performance | Slower | Faster & lightweight |
| LINQ Features | Mature | Constantly improving |
| Cross-platform | No | Yes |

## Answers

### Answer by Utpal Vishwas

**EF Core (Entity Framework Core)** is a **lightweight, extensible, open-source, cross-platform Object-Relational Mapper (ORM)** developed by Microsoft. It is the modern version of Entity Framework and is used to interact with relational databases using C# objects.

## Key Features of EF Core

| Feature | Description |
| --- | --- |
| **ORM** | Maps C# classes to database tables and columns. |
| **LINQ Support** | Query the database using LINQ syntax. |
| **Migrations** | Handles schema changes through code-based migrations. |
| **Cross-platform** | Works on Windows, Linux, macOS. |
| **Database Providers** | Supports SQL Server, SQLite, PostgreSQL, MySQL, Oracle, etc. |
| **Change Tracking** | Automatically tracks changes to objects for `Insert`, `Update`, or `Delete`. |

## How EF Core Works

## Define a Model (C# Classes)

```cs
public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
}
```

**Create a** `DbContext` **Class**

```cs
public class AppDbContext : DbContext
{
    public DbSet<Product> Products { get; set; }

    public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
}
```

**Configure EF Core (e.g., in** `Startup.cs` **or** `Program.cs`**)**

```cs
services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer("Your_Connection_String"));
```

## Use EF Core in Code

```cs
public class ProductService
{
    private readonly AppDbContext _context;

    public ProductService(AppDbContext context)
    {
        _context = context;
    }

    public List<Product> GetAll()
    {
        return _context.Products.ToList();
    }
}
```

## Advantages

1. No need to write SQL for most queries.
2. Keeps code DRY by centralizing models.
3. Works well with ASP.NET Core and dependency injection.
4. Supports unit testing with in-memory databases.

## EF Core vs EF 6

| Feature | EF 6 | EF Core |
| --- | --- | --- |
| Platform | .NET Framework only | .NET Core & .NET 5+ |
| Performance | Slower | Faster & lightweight |
| LINQ Features | Mature | Constantly improving |
| Cross-platform | No | Yes |


---

Original Source: https://www.mindstick.com/interview/34144/what-is-ef-core

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
