Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do ASP.NET MVC view scaffolding in Rider IDE?

Currently trying Rider (JetBrains IDE for .Net). I used to work on Visual Studio Enterprise for c# asp.net MVC projects, and i'd like to know if there's a way (on Rider) to do like the "Add -> view -> with create/delete/update/list" feature on Visual Studio?

Something which would generate CRUD views like that :

@model IEnumerable<Web.Models.Warrior>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Health)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Health)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
            @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
            @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
        </td>
    </tr>
}

</table>

PS : if there's a way to do it with controllers to... :D

like image 347
j0w Avatar asked Apr 25 '18 16:04

j0w


People also ask

How do you use scaffolding in MVC?

To add a scaffold, right-click on Controllers folder in the Solution Explorer and select Add → New Scaffolded Item. It will display the Add Scaffold dialog. Select MVC 5 Controller with views, using Entity Framework in the middle pane and click 'Add' button, which will display the Add Controller dialog.

How do I add a view on Rider?

Place the cursoron the return View(); statement and press Alt+Enter to launch Rider's Create Razor views intention.

How do you add a scaffold code in Visual Studio?

In the VS Code File menu, select Preferences then Settings. Expand Extensions then find Docs Scaffolding Extension Configuration.


3 Answers

But you still can...

You can use dotnet aspnet-codegenerator terminal tool. which is used for generating controllers and views with different options.

Install the tool globally.

dotnet tool install --global dotnet-aspnet-codegenerator

dotnet aspnet-codegenerator controller -name MyNewController -m MyModel -dc MyDbContext -outDir Controllers/

like image 163
bereket gebredingle Avatar answered Nov 16 '22 13:11

bereket gebredingle


You can vote\track this issue: https://youtrack.jetbrains.com/issue/RIDER-12363

like image 26
xtmq Avatar answered Nov 16 '22 13:11

xtmq


This is called Scaffolding and is unfortunately not a feature in Rider. I couldn't tell you if it's a planned feature, but I hope so.
My only suggestion might be to open VS, scaffold, and then use Rider again to continue coding.

like image 1
brad Avatar answered Nov 16 '22 13:11

brad