Performing CRUD operations
We have already seen how to create CRUD operations right from scaffolding controllers to their corresponding views for the Blog
model, so we will create them for the Post
model in this section:
- Right-click on the
Controllers
folder and selectAdd
 |ÂNew Scaffolded Item.
- Â
Add Scaffold
dialog box, selectMVC Controller with views, using Entity Framework
:
- In theÂ
Add Controller
 dialog box, select the appropriateÂModel class
 andÂData Context
class (Post
 andÂMasteringEFCoreDbFirstContext
 in our case) along with the auto-generated controller name,ÂPostsController
:
- Next click Add as shown in the following screenshot:
Scaffolded items
Note
The Blog URL should be displayed instead of the Blog ID, which was part of the scaffolding. As displaying the ID raises security issues and usability concerns, let's change this mapping to URL.
Let's start our changes from the Index.cshml
file, where we have listed Blog.Id
instead of Blog.Url
:Â
@foreach (var item in Model) { <tr>...