Skip to content
Sample project to demonstrate the implementation (workaround) of raw queries in Entity Framework Core
HTML C# CSS Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SampleWithEFCore
.gitignore
LICENSE
README.md
StudentDetails.PNG

README.md

About

This sample demonstrates how to implement raw SQL Queries in ASP.NET Core. The main query is calculating the student grade.

Project Structure

This sample consists of 2 separate projects:

  • SampleWithEFCore : ASP.NET Core 2.1 with Entity Framework Core
  • SampleWithEF6 + EF6: ASP.NET Core 2.1 with data layer separate as library using Entity Framework 6

Disclaimer

I used Microsoft sample Contoso University and simply modified it.

Get Started

  1. Start with the first project (SampleWithEFCore). When you run it, it will create a local DB because it has a DbInitialzer file.
  2. When you run the app, call https://localhost:44385/api/Students/GetScore?studentId=1 to get the grade of the student.
    * There are different APIs, you can find all of them in the StudentsController.
    The implementation of the raw query using Entity Framework Core and ADO.NET are in the StudentRepository.
  3. Now, you can set SampleWithEF6 as StartUp Project.
  4. Run the app, then click on students in the nav bar. After that, click in user details. You will find the score in the last raw.

StudentDetails

You can’t perform that action at this time.