Command-Line Scaffolding for Syncfusion Blazor and ASP.NET Core Components: A Time-Saving Essential
Tags: scaffolding, webdev, productivity, blazor
Published: 2020-07-29 12:11:21

---
title: Command-Line Scaffolding for Syncfusion Blazor and ASP.NET Core Components: A Time-Saving Essential
published: true
date: 2020-07-23 10:30:12 UTC
tags: scaffolding, webdev, productivity, blazor
canonical_url: https://www.syncfusion.com/blogs/post/command-line-scaffolding-for-syncfusion-blazor-and-asp-net-core-components-a-time-saving-essential.aspx
cover_image: https://www.syncfusion.com/blogs/wp-content/uploads/2020/07/Command-Line-Scaffolding-for-Syncfusion-Blazor-and-ASP.NET-Core-Components-A-Time-Saving-Essential-1-672x372.jpg
---

Syncfusion is glad to announce that [command-line scaffolding](https://www.nuget.org/packages/Syncfusion.Scaffolding/) support for Syncfusion [Blazor](https://www.syncfusion.com/blazor-components) and [ASP.NET Core](https://www.syncfusion.com/aspnet-core-ui-controls) components is available with our [2020 Volume 2](https://www.syncfusion.com/forums/155798/essential-studio-2020-volume-2-release-v18-2-0-44-is-available-for-download) release.

In this blog, we will explain how to use command-line scaffolding in Blazor and ASP.NET Core applications with the Syncfusion [DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) control as an example.

## Prerequisites

Install [.NET Core 3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1) SDK or [later](https://dotnet.microsoft.com/download/visual-studio-sdks).

## What is command-line scaffolding?

Scaffolding is a code-generation framework for ASP.NET applications that creates a controller and views from existing models in the application.

Command-line scaffolding is similar, but it generates controller and view files through a command line without using Visual Studio. With it, a developer can reduce the amount of time needed to create the controller and views in their applications.

## Syncfusion command-line scaffolding

Syncfusion provides command-line scaffolding support for some of its **Blazor** and **ASP.NET Core** components.

The following Syncfusion controls support command-line scaffolding:

- DataGrid
- Charts
- TreeGrid
- Scheduler
- Diagram
- Rich Text Editor
- Document Editor
- PDF Viewer

**Note:** In Blazor, WebAssembly apps are not supported by Syncfusion command-line scaffolding.

## Install command-line scaffolding

Install the **Syncfusion.Scaffolding** tool globally by using the following command.

| `dotnet tool install -g Syncfusion.Scaffolding` |

## Update command-line scaffolding

Use the following update command if you have already installed **Syncfusion.Scaffolding** to use the latest version.

| `dotnet tool update -g Syncfusion.Scaffolding` |

## Model and DB context classes

To perform Syncfusion scaffolding, you should use model and DB context classes in your application. If you haven’t included these classes before, follow these steps to create the Model and DB context classes in your application:

**Step 1:**  Create a new database and table using  **SQL Server**.

**Step 2:**  Open an existing Blazor or ASP.NET Core application project or create a new one using Visual Studio. For this blog, I have created an ASP.NET Core application.

**Step 3:**  Install the following NuGet packages in your application:

- AspNetCore.Mvc.NewtonsoftJson
- EntityFrameworkCore.SqlServer
- EntityFrameworkCore.Tools
- Extensions.Logging.Debug
- VisualStudio.Web.CodeGeneration.Design

**Step 4:**  To connect your SQL Server, go to  **View > SQL Server Object Explorer.**  In the SQL Server Object Explorer, right-click your database, and then copy the connection string.

**Step 5:**  Open the  **Package Manager Console**  by selecting the project and then go to  **Tools > NuGet Package Manager > Package Manager Console**.

**Step 6:**  Execute following commands in the Package Manager Console with the copied connection string:

| `>Scaffold-DbContext “{Connection String}” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Context “{Db context class name}” -DataAnnotations` |

**Step 7:**  The **Model ** and  **DbContext**  classes will be created in your application. Next, build the project.

## How to use Syncfusion command-line scaffolding

Let’s see how to perform command-line scaffolding.

After installing the **Syncfusion.Scaffolding** tool, we can invoke the **syncfusion\_scaffold** command to generate the controller and view files through the command line by passing arguments. For example:

| `syncfusion_scaffold DataGrid --project "D:\Webapplication1\ Webapplication1.csproj" --model WebApplication1.Models.Orders -dc Webapplication1.Models. Northwindcontext -dsource LocalData -cname DataGridController -vname Index -cfolder Controllers -vfolder Views -pkey id` |

![scaffolding command parameters](https://dev-to-uploads.s3.amazonaws.com/i/sgsb4gtb07jr6xjcbf6p.png)

After running the above command, we should see command-line output like the following screenshot during scaffold generation.

![Generating Controller and View Files](https://www.syncfusion.com/blogs/wp-content/uploads/2020/07/Generating-Controller-and-View-Files.png)<figcaption>Generating Controller and View Files</figcaption>

Now, we can see that the controller and view files have been generated successfully and the Syncfusion NuGet packages and styles required to render the Syncfusion control have been added.

In the **ASP.NET Core** project **, controller** and **view** files will be added as shown in the following screenshot.

![Controllers, Views, and NuGet Packages Added](https://www.syncfusion.com/blogs/wp-content/uploads/2020/07/Controllers-Views-and-NuGet-Packages-Added-1.png)<figcaption>Controllers, Views, and NuGet Packages Added</figcaption>

![Syncfusion Styles Added in ASP .NET Core Project](https://www.syncfusion.com/blogs/wp-content/uploads/2020/07/Syncfusion-Styles-Added-in-ASP-.NET-Core-Project-1.png)<figcaption>Syncfusion Styles Added in ASP .NET Core Project</figcaption>

For the **Blazor** project, controller and Razor files will be added as shown in the following screenshot.

![](https://www.syncfusion.com/blogs/wp-content/uploads/2020/07/Controllers-and-Razor-Files-Added.png)<figcaption>Controllers and Razor Files Added</figcaption>

![Syncfusion Styles Added in Blazor Project](https://www.syncfusion.com/blogs/wp-content/uploads/2020/07/Syncfusion-Styles-Added-in-Blazor-Project.png)<figcaption>Syncfusion Styles Added in Blazor Project</figcaption>

Then, add navigation to the created view file based on your requirements to open the view in the web page. ** **

## Conclusion

In this blog, we have seen the new command-line scaffolding support for the Syncfusion [Blazor](https://www.syncfusion.com/blazor-components) and [Asp.NET Core](https://www.syncfusion.com/aspnet-core-ui-controls) platforms. Use Syncfusion command-line scaffolding in your project to quickly add code that interacts with data models. Using it can reduce the amount of time it takes to develop standard data operations in your project.

Syncfusion provides 70+ high-performance, lightweight, modular, and responsive UI controls for [ASP.NET Core](https://www.syncfusion.com/aspnet-core-ui-controls) and [Blazor](https://www.syncfusion.com/blazor-components) platforms, such as [DataGrid](https://www.syncfusion.com/aspnet-core-ui-controls/grid), [Charts](https://www.syncfusion.com/aspnet-core-ui-controls/charts), and [Scheduler](https://www.syncfusion.com/aspnet-core-ui-controls/scheduler). You can use these controls to speed up your application development.

Which control do you want scaffolding support for next? Let us know in the comment section below. You can also contact us through our [support forum](https://www.syncfusion.com/forums), [Direct-Trac](https://www.syncfusion.com/support/directtrac/incidents), or [feedback portal](https://www.syncfusion.com/feedback/). We will implement features based on the number of customers requesting them.