Skip to content

nayanbunny/dotnet-entity-framework-core-sample

Repository files navigation

DotNet Entity Framework Core Sample

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

EF Core can serve as an object-relational mapper (O/RM), which:

  • Enables .NET developers to work with a database using .NET objects.
  • Eliminates the need for most of the data-access code that typically needs to be written.

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

Entity Framework development approaches:

  • Code First
  • Code First - Fluent API
  • Database First
  • Model First

EF Core Development Approach

Entity Framework Development Approach Decision

EF Core Development Approach Decision

Entity Framework development approaches in .NET Core

Feature Code First Code First - Fluent API Database First Model First
Definition Create a database from the model, and then add data to the database. Create a database from the model, and then add data to the database. ModelBuilder class acts as a Fluent API. Creating entity & context classes for an existing database. Create a new model using the Entity Framework Designer and then generate a database schema from the model.
Suitable Application Greenfield / Brownfield Greenfield Brownfield Greenfield
Application Size Small Small Large Small / Medium
Data Intensity No No Yes No
Version Control Yes Yes No Yes
GUI No No Yes Yes (Slow / Laggy)
Code Development Ease Ease Moderate Moderate
DB Maintenance Moderate Moderate Ease Bit Hard (Laggy GUI)
Query Data LINQ LINQ LINQ / Stored Procedure LINQ

Language : C#
.Net Version : >=6.0

Pre-Requisites

  • Visual Studio IDE
  • Microsoft SQL Server
  • Azure Data Studio / SQL Server Management Studio (SSMS) / SSDT for Visual Studio

Scenario

  • Database with tables:
    • Departments (Departments data like Name, IsActive)
    • Employees (Employee data like Name, Email, Phone, DepartmentId, IsActive)
    • Skills (Skills data like Name, IsActive)
    • EmployeeSkills (Relation Mapping between Employee and Skill)
  • Each Employee belongs to a department and can have multiple skills.

Execution & Implementation Steps

References

EntityFrameworkCore
Entity Framework Core Tutorial
EF Core and EF6
.Net Core MVC
EFCore - Get Started

🔥 Happy Coding