alternative method for database connection in .net core web api

Mahadevi Thirumagan 0 Reputation points
2024-07-27T11:53:28.1333333+00:00

In .NET Core Web API, linking to and managing an existing database is more complex than in .NET Framework. I need a way to add existing tables to models and a simple method to connect, update, and alter tables. Any straightforward approach?

ASP.NET Core Training
ASP.NET Core Training
ASP.NET Core: A set of technologies in the .NET Framework for building web applications and XML web services.Training: Instruction to develop new skills.
73 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 30,041 Reputation points
    2024-07-27T14:33:58.6966667+00:00

    I need a way to add existing tables to models and a simple method to connect, update, and alter tables. Any straightforward approach?

    A simple CLI command generates C# models from tables in EF Core.

    https://learn.microsoft.com/en-us/ef/core/managing-schemas/scaffolding/?tabs=dotnet-core-cli

    Likewise, scaffolding Web API controllers can be done with a CLI command or in Visual Studio.

    https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-8.0&tabs=visual-studio

    0 comments No comments

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.