general question about EntityFramework

elsvieta 371 Reputation points
2023-10-19T22:02:05.6466667+00:00

hi all,

I am trying to re-write an old framework .NET 4.0 project to ASP.NET Core MVC .NET 7 and I have a few questions:

  1. is it mandatory to use Entity Framework in a Core MVC project?
  2. can I simply use database connections to retrieve and update data using existing stored procedures?
  3. I just started reading about MVC and it seems that there are lots of differences between types of projects and versions of .NET: some projects provide a Data folder by default with an ApplicationDbContext.cs class, some are not providing the Data folder. Some older versions use to have a Startup.cs, currently everything moved to Program.cs.

I intend to use VS 2022 and .NET 7 for an ASP.NET Core Web App (Model-View-Controller) project. Is there a consistent documentation you can point at?

Thank you very much,

elsvieta

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2023-10-20T10:02:44.2566667+00:00

    is it mandatory to use Entity Framework in a Core MVC project?

    Use ADO.NET if you like. Keep in mind, EF Core is built on top of ADO.NET. EF Core can easily call a stored procedure.

    SQL Queries

    can I simply use database connections to retrieve and update data using existing stored procedures?

    Yes. ASP.NET Core has dependency injection to pass a configuration service to a constructor. The configuration service is used to get to the connection string from appsettings.json.

    ASP.NET Core fundamentals overview

    Dependency injection in ASP.NET Core

    Configuration in ASP.NET Core

    I just started reading about MVC and it seems that there are lots of differences between types of projects and versions of .NET: some projects provide a Data folder by default with an ApplicationDbContext.cs class, some are not providing the Data folder. Some older versions use to have a Startup.cs, currently everything moved to Program.cs.

    Correct ASP.NET Core is very different from ASP.NET framework. Set aside some time to read the ASP.NET Core fundamentals overview and go through a few tutorials to get a feel for ASP.NET Core.

    Razor Pages with Entity Framework Core in ASP.NET Core - Tutorial 1 of 8

    ASP.NET Core MVC with EF Core - tutorial series

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.