.NET Core doesn't support Database First (EDMX files). But it supports Code First from an existing database. You use ef commands to generate a model from the existing database:
1° How to generate the Models from existing Database?
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.
Skar.2007
2° How create Forms from Models?
Not clear about what do you mean for creating forms for models.
Skar.2007
3° Always from Visual Studio Code, how are the CRUD Maintenance Pages automatically generated?
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
10 Points
13 Posts
Razor Pages: Database First
Sep 30, 2020 07:31 AM|Skar.2007|LINK
Visual Studio Code 1.48 | .NET Core 3.1
Hi all
There is a Web Application without Controllers (no MVC), and there is a Database in SQL Server.
It is required to use Database First approach from Visual Studio Code.
1° How to generate the Models from existing Database?
2° How create Forms from Models?
3° Always from Visual Studio Code, how are the CRUD Maintenance Pages automatically generated?
Thank you very much
All-Star
194428 Points
28073 Posts
Moderator
Re: Razor Pages: Database First
Sep 30, 2020 09:12 AM|Mikesdotnetting|LINK
.NET Core doesn't support Database First (EDMX files). But it supports Code First from an existing database. You use ef commands to generate a model from the existing database:
https://www.learnentityframeworkcore.com/walkthroughs/existing-database
Then you can use scaffolding commands to generate the CRUD pages:
https://www.learnrazorpages.com/miscellaneous/scaffolding
Contributor
2690 Points
874 Posts
Re: Razor Pages: Database First
Oct 01, 2020 07:44 AM|Rena Ni|LINK
Hi Skar.2007,
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.
Not clear about what do you mean for creating forms for models.
You could refer to the document:
https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.1&tabs=visual-studio-code#scaffold-the-movie-model
Best Regards,
Rena