Generated MVC View: Books/Create.cshtml


Clicking on the hyperlink of the view Books/Index.cshtml, the view Books/Create.cshtml will be displayed as follows:



 



The Entity Framework (EF) Core automatically creates the database BookStore3Context including two tables Book and Author. The tables are populated via the web browser and an instance are shown below:


C:\ASP.NET-workspace\BookStore3\Views\Books\Create.cshtml
 @model BookStore3.Models.Book

 @{ ViewData["Title"] = "Create"; }

 <h1>Create</h1><h4>Book</h4><hr />
 <div class="row">
   <div class="col-md-4">
     <form asp-action="Create">
       <div asp-validation-summary="ModelOnly" class="text-danger"></div>

       <div class="form-group">
         <label asp-for="Title" class="control-label"></label>
         <input asp-for="Title" class="form-control" />
         <span asp-validation-for="Title" class="text-danger"></span>
       </div>

       <div class="form-group">
         <label asp-for="Price" class="control-label"></label>
         <input asp-for="Price" class="form-control" />
         <span asp-validation-for="Price" class="text-danger"></span>
       </div>

       <div class="form-group">
         <label asp-for="PublishDate" class="control-label"></label>
         <input asp-for="PublishDate" class="form-control" />
         <span asp-validation-for="PublishDate" class="text-danger"></span>
       </div>

       <div class="form-group">
         <input type="submit" value="Create" class="btn btn-primary" />
       </div>
     </form>
   </div>
 </div>

 <div><a asp-action="Index">Back to List</a></div>

 @section Scripts {
   @{ await Html.RenderPartialAsync( "_ValidationScriptsPartial "); }
 }




      “I just joined a gym.    
      I don’t work out there,    
      I just joined it.    
      It’s nice to have something to cancel.”    
      — Todd Barry