Showing posts with label Entity Framework Core. Show all posts
Showing posts with label Entity Framework Core. Show all posts
Saturday, May 18, 2019
Wednesday, March 27, 2019
Creating a Delete view using EF Core
In the previous posts we
created a List, Details and Edit views using Asp.Net Core MVC and Entity
Framework Core to connect to Database view and edit details from SQL Server DB. In this post we will see
on how to create a Delete view which will display the details of an Entity
object (User) and allow us to delete the User from the database.
Similar to Edit, the delete operation will use 2 action methods. A GET method to get and display user details and a POST method to delete the user from the DB.
Similar to Edit, the delete operation will use 2 action methods. A GET method to get and display user details and a POST method to delete the user from the DB.
Creating an Edit view and display data using EF Core
In the previous post we
saw on how to create a Details view using Asp.Net
Core MVC and Entity Framework Core
and display the details of an users from the Users table in SQL Server database. In this post we
will create an Edit view which will be used to edit the user details.
Remember we had an Edit action link in the list this view will be linked to the Edit link, on clicking the Edit link against a user will trigger the Edit action method in the controller which in turn will get the user details from the DB using Entity Framework Core and pass on the Model object to the View to render the user details in the browser, which can be edited and saved.
Edit and Save will use 2 different action methods a GET and A POST action method, the GET method will get the user details from the DB and the POST method will be used to save the details back to the DB.
Remember we had an Edit action link in the list this view will be linked to the Edit link, on clicking the Edit link against a user will trigger the Edit action method in the controller which in turn will get the user details from the DB using Entity Framework Core and pass on the Model object to the View to render the user details in the browser, which can be edited and saved.
Edit and Save will use 2 different action methods a GET and A POST action method, the GET method will get the user details from the DB and the POST method will be used to save the details back to the DB.
Saturday, March 16, 2019
Creating a Detail view and display data using EF Core
In the previous post we
saw on how to create a List view using Asp.Net
Core MVC and Entity Framework Core
and display a list of users from the Users table in SQL Server database. In
this post we will create a Details view which will display the user details of
a specific user.
Remember we had a Details action link in the list this view will be linked to the Details link, on clicking the Details link against a user will trigger the Details action method in the controller which in turn will get the user details from the DB using Entity Framework Core and pass on the Model object to the View to render the user details in the browser.
Remember we had a Details action link in the list this view will be linked to the Details link, on clicking the Details link against a user will trigger the Details action method in the controller which in turn will get the user details from the DB using Entity Framework Core and pass on the Model object to the View to render the user details in the browser.
Creating a List view and display data using EF Core
In the previous post we
created an MVC Controller for our Asp.Net Core application using Entity Framework core. In this post we
shall create a List view which will display the list of users in the database
fetched using. Let us start by adding a view to our Index action method. Entity Framework Core
Visual studio has already added code in the Index action method of the controller to fetch the list of users using Entity Framework Core.
Visual studio has already added code in the Index action method of the controller to fetch the list of users using Entity Framework Core.
Thursday, March 14, 2019
Creating a controller for CRUD operation using EF Core
In the previous post we
saw on how to setup Entity Framework Core for out Asp.Net Core application. In
this post we will use the EFCore and
create a controller for CRUD operation.
In this sample we will not do too many customization we will rather use the
Built in Scaffolding from Visual Studio to create the controller.
In Visual Studio Right-click on the Controllers folder in Solution Explorer and select Add > Controller.
In Visual Studio Right-click on the Controllers folder in Solution Explorer and select Add > Controller.
Setting up Entity Framework Core for MVC Database First Application
So
far we have seen simple examples using Asp.Net
MVC to display static messages and static list of model objects, however
complex applications will have to deal with database display and update data
from the database. In the previous versions of .Net / MVC we used Entity Framework to interact with the
database with .Net Core we will use Entity Framework Core to interact with
the database. In this post we shall see on how to set up EF core to interact
with the database.
First step to setup EFCore is to create a Models folder, let us create a folder EFCoreModel in the project. Next we need to add the following 3 NuGet packages to the project we can do this either using Package Manager GUI or Package Manager console.
First step to setup EFCore is to create a Models folder, let us create a folder EFCoreModel in the project. Next we need to add the following 3 NuGet packages to the project we can do this either using Package Manager GUI or Package Manager console.
Subscribe to:
Posts (Atom)