Resolved Can we use ADO.NET with ASP.Net Core Web App(MVC) ?

Anonymous

Well-known member
Joined
Sep 29, 2020
Messages
84
Programming Experience
Beginner
I am learning MVC. I had previously worked on ASP.Net Web Applications(.NET Framework) in which we used webforms, edmx, and ado.net to connect to the database for CRUD operations. But I don't see any edmx option in ASP.Net Core Web App(MVC) .

I want to create a login page . I have the following table and stored procedure in SQL Server -


C#:
create table users(userId int identity(1,1) primary key, username varchar(20), password varchar(20))

C#:
create proc login(
@username varchar(20),
@password varchar(20)
)
as
begin
if exists(select * from users where username = @username and password=@password)
select 'Success' as UserExists
else
select 'Failed' as UserExists
end

I have created a model class

C#:
public class Login
    {
        [Key]
        public int userID { get; set; }

        [Required(ErrorMessage = "Username is required")]
        public string username { get; set; }

        [Required(ErrorMessage = "Password is required")]
        public string password { get; set; }
    }

I don't know how to access the stored procedure in MVC for the login page.

Also, I have heard that webforms are now obsolete. So, I wanted to learn the new way of doing CRUD operations. Is ASP.Net Web Applications(.NET Framework) with ADO.NET also going to be obsolete?
 
EDMX is Entity Framework with designer, which is not supported in EF Core. If you want to use EF Core then you should probably use Code First. You should do some reading on that subject.
 
Is
EDMX is Entity Framework with designer, which is not supported in EF Core. If you want to use EF Core then you should probably use Code First. You should do some reading on that subject.
Is it okay to use mvc with ado.net? Like can i write ado.net code in controller or make a separate class file that handles the ado.net part? I want to authenticate a user for login here, so after my model class, what is the way that I can proceed further?
 
EDMX is Entity Framework with designer, which is not supported in EF Core. If you want to use EF Core then you should probably use Code First. You should do some reading on that subject.
I have read a bit about ef core and i think it uses migration... I dont want to use that i just want to know a database connection method that works with mvc and is not obsolete.
 
Yes, you can use ADO.NET with ASP.NET MVC and ASP.NET Core MVC. The issue is that you want to use the GUI designer which is not part of ADO.NET. The GUI designer is part of Visual Studio.
 
It's weird that you're talking about EDMX and ADO.NET, because they are different things. If you want to use ADO.NET then go ahead. That means types like SqlConnection and SqlDataAdapter. That hasn't changed in .NET Core. If you were using an EDMX file though, that's not ADO.NET. That Entity Framework. It uses ADO.NET under the hood but you never touch that layer. If you want to use EF in .NET Core then you'll be using EF Core, which does not support EDMX or a designer. If you want to use database-first with EF Core then you can, and you can research that specifically, but there will be no EDMX designer.
 
Back
Top Bottom