Skip to content

This repository is a playground for Entity Framework Core.

License

Notifications You must be signed in to change notification settings

m7moudGadallah/EFCorePlayground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EF Core Playground

This repository is a playground for Entity Framework Core. It contains a simple console application that demonstrates how to use EF Core to interact with a SQLServer database.

Overview

In this project, I try to practice the following concepts:

Database Schema

Look at the database schema using DBML file here

ERD

Note

There is another approach for this design to create parent table for Student and Instructor tables, and use Discriminator column to differentiate between them. But I wanted to keep it simple and separate them.

How to run

  1. Clone this repository

    git clone <repo_url>
  2. Open the solution file in Visual Studio

  3. In Config Project, Copy app.settings.example.json and Create app.settings.json file in the same directory and fill in the connection string.

  4. Restore the NuGet packages, by right-clicking on the solution and selecting Restore NuGet Packages.

  5. Build the solution.

  6. Run the console application project you want to run.

Note

if you want to run the DbFirst project, you need to create a database first (using the scripts provided in the scripts directory) and update the connection string in the app.settings.json file and then run scaffold-dbcontext command to generate the models.

File Structure

EFPlayground
├── EFPlayground.sln
├── Config
│   ├── app.settings.example.json
│   ├── app.settings.json
├── DbFirst
│   ├── Program.cs
│   ├── Models
│   │   ├── SchoolContext.cs # (Add by EF Core)
│   │   ├── SchoolContext.Developer.cs #(Added by me to add custom methods)
│   │   ├── Student.cs #(Added by EF Core)
│   │   ├── Student.Developer.cs #(Added by me to add custom methods)
├── CFDataAnnotations
│   ├── Program.cs
│   ├── Models
│   │   ├── Student.cs
│   ├── Database
│   │   ├── SchoolDbContext.cs
├── CFFluentAPI
│   ├── Program.cs
│   ├── ModelConfigurations
│   │   ├── StudentConfiguration.cs
│   ├── Models
│   │   ├── Student.cs
│   ├── Database
│   │   ├── SchoolDbContext.cs
├── docs
│   ├── database.dbml
│   ├── erd.png
├── scripts
│   ├── create_db.sql
│   ├── populate_db.sql
├── .gitignore
├── README.md

License

This repository is licensed under the MIT License - see the LICENSE file for details.

About

This repository is a playground for Entity Framework Core.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published