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

3

7

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

Garrik answered 25/4, 2018 at 16:40 Comment(1)
Related question: #46063451Parotic
F
5

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

Feudist answered 25/4, 2018 at 20:12 Comment(1)
Thanks for the track link, i'll keep an eye on it! :)Garrik
B
13

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/

Bacchae answered 22/3, 2019 at 12:4 Comment(0)
F
5

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

Feudist answered 25/4, 2018 at 20:12 Comment(1)
Thanks for the track link, i'll keep an eye on it! :)Garrik
P
1

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.

Parotic answered 25/4, 2018 at 19:13 Comment(2)
Well, thanks for the "scaffolding" word I didn't knew. Your solution may be one solution (not sure if it's the optimal solution but .. meh, why not xD) or i'll wait till JetBrains implements it in Rider...Garrik
You're welcome! Yeah I hope they implement it too :)Parotic

© 2022 - 2024 — McMap. All rights reserved.