Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Core without migrations for existing SQL Server database

Evening.

I have to develop an api for an existing SQL Server 2017 database.

I need to use Microsoft Web API, and I would like to use Core 3.1 but I have read I have to use migrations and such, and i have been told not to build the api using migrations.

Would I be better using .Net Framework instead or is there a way to use Core without using migrations?

I hope that it's not too broad a question, but I really am struggling to make a decision so any feedback etc would be greatly appreciated.

carlson

like image 343
carlson46uk4 Avatar asked Aug 31 '26 09:08

carlson46uk4


1 Answers

If you'd like to access data from an existing database and tables with Entity Framework (EF) Core in your ASP.NET Core Web API project, you can try to use Scaffold-DbContext command or dotnet ef dbcontext scaffold command to generate code for a DbContext and entity types for your database.

enter image description here

Besides, you can also install and use Microsoft.Data.SqlClient to access your existing SQL Server database in ASP.NET Core project.

like image 78
Fei Han Avatar answered Sep 02 '26 05:09

Fei Han