Skip to content
Advertisement

ASP.NET Core display all rows in database on page

I am trying to display every row from a database on a website with ASP.NET Core MVC, but I cannot find any source on how to do it.. This is what Ive tried to do but I got stuck:

My Database is structured like this: Id, Username, Password, PasswordHash, but I only want to display Username to begin with.

If you have any sources or ideas it would be very appriciated! Thanks beforehand!

Best Regards Max

Advertisement

Answer

I recommend you to use the biggest ORM for .NET, Entity Framework.

Create this

Add to the ConfigureServices method in Startup.cs

On your controller

Then, on your view

References https://learn.microsoft.com/pt-br/ef/core/dbcontext-configuration/

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement