Command-Line Scaffolding for Syncfusion Blazor and ASP.NET Core Components: A Time-Saving Essential | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (172).NET Core  (29).NET MAUI  (186)Angular  (105)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (208)BoldSign  (12)DocIO  (24)Essential JS 2  (106)Essential Studio  (199)File Formats  (63)Flutter  (129)JavaScript  (217)Microsoft  (118)PDF  (80)Python  (1)React  (97)Streamlit  (1)Succinctly series  (131)Syncfusion  (866)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (49)Windows Forms  (61)WinUI  (68)WPF  (155)Xamarin  (160)XlsIO  (35)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (145)Chart  (123)Cloud  (14)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (62)Development  (603)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (37)Extensions  (22)File Manager  (6)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (479)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (39)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (29)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (358)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (30)Visual Studio Code  (17)Web  (567)What's new  (311)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Command-Line Scaffolding for Syncfusion Blazor and ASP.NET Core Components: A Time-Saving Essential

Command-Line Scaffolding for Syncfusion Blazor and ASP.NET Core Components: A Time-Saving Essential

Syncfusion is glad to announce that command-line scaffolding support for Syncfusion Blazor and ASP.NET Core components is available with our 2020 Volume 2 release.

In this blog, we will explain how to use command-line scaffolding in Blazor and ASP.NET Core applications with the Syncfusion DataGrid control as an example.


Install .NET Core 3.1 SDK or later.

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
DataGridSpecifies the control name.
-p|–projectSpecifies the .csproj file path of the ASP.NET Core or Blazor project.
-m|–modelSpecifies the name of the database model with a namespace.
-dc|–db-contextSpecifies the DB context name with a namespace.
-dsource|–data-sourceSpecifies the data source type, which is LocalData or RemoteData.
-cname| –controller-filenameSpecifies the name of the controller file to be added to the project.
-vname |–view-filenameSpecifies the name of the view file to be added to the project.
-pkey|–primary-keySpecifies a primary key for database columns.

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

Generating Controller and View Files
Generating Controller and View Files

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
Controllers, Views, and NuGet Packages Added
Syncfusion Styles Added in ASP .NET Core Project
Syncfusion Styles Added in ASP .NET Core Project

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

Controllers and Razor Files Added
Syncfusion Styles Added in Blazor Project
Syncfusion Styles Added in Blazor Project

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


In this blog, we have seen the new command-line scaffolding support for the Syncfusion Blazor and Asp.NET Core 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 and Blazor platforms, such as DataGridCharts, and 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 forumDirect-Trac, or feedback portal. We will implement features based on the number of customers requesting them.


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top