ASP.net core find model.primary_key_field_name in custom scaffolding

51 views Asked by At

I have an asp.net core MVC project I am creating custom scaffolding template files

I am following this answer to add custom scaffolding template pages

on Details page I want o add link to Listing, Edit and Delete page as below

@using System.Linq
@@model @Model.ViewDataTypeName

@:    <div class="card-body py-2">
@:        <a asp-action="Delete" asp-route-id="@@Model.pkName" class="float-right btn-floating btn-sm btn-danger m-0" title="Delete @Model.ViewDataTypeShortName Record"><i class="fa fa-trash"></i></a>    
@:        <a asp-action="Edit" asp-route-id="@@Model.pkName" class="float-right btn-floating btn-sm btn-warning m-0 mr-2" title="Edit @Model.ViewDataTypeShortName Record"><i class="fa fa-edit"></i></a>   
@:        <a asp-action="Index" class="float-right btn-floating btn-sm btn-info m-0 mr-2" title="Back to @Model.ViewDataTypeShortName listing page"><i class="fa fa-arrow-left"></i></a>    
@:        <h4 class="mb-2 mb-sm-0 pt-1">@Model.ViewDataTypeShortName Details</h4>
@:    </div>

Notice asp-route-id="@@Model.pkName" in above example, Actualloy here I need to put primaryKey field name dynamically, @@Model.pkName is not a valid property but I just wanted to show something here.

0

There are 0 answers