Attention! Updated package to NuGet. Details at the end of the article.
With the release of Visual Studio 2013, ASP.NET MVC 5 and Entity Framework 6, the scaffolding capabilities built into Visual Studio are even better. However, until now creating a new web application has to do a lot of actions that could be automated.
Therefore, the X.Scaffolding package was created for myself and the developers with whom I work. It allows you to create web applications more productively. It is on the basis of this package that we now develop the majority of new web applications for working with data.
')
Today I decided to share this project with Habrahabr readers. Perhaps someone will find it interesting and will help in his work, and someone himself will want to participate in its development.
As you know, Visual Studio provides a huge number of functions that allow you to automate routine operations and focus on basic tasks. One of such convenient and rather demanded functions is the possibility of generating editing forms for database entities. This feature has appeared a long time ago, but with the release of Visual Studio 2013, the bootstrap framework has become even more convenient for integrating into the base application template. But as you know - the limit is not perfect.
One of the reasons for creating a package was that now standard controls created by various extension methods like EditorFor generate incompletely valid code from the point of view of the bootstrap framework. As a result, the pages with editors are not very well displayed. In order to avoid manual editing of styles, a set of own extension methods was also developed.
In addition, not all data types are currently supported by standard extensions. For example, now many of my projects often use the capabilities of the package for creating an HTML editor, calendar, and video preview.
Extensions
The key role in the library is played by the Extensions class, which contains extension methods for HtmlHelper):
- HtmlEditorFor - displays an HTML editor based on CKEditor 4
- DatePickerFor - displays the bootstrap-style calendar
- FileUploadFor - displays the item to download the file
- ThumbnailFor - displays the bootstrap-style prview for the image
- TextEditorFor - displays the bootstrap-style editor
- MultilineTextEditorFor - displays a multi-line bootstrap-style editor
- EmailEditorFor - displays bootstrap-style editor that has HTML5 email type
- VideoPlayerEditorFor - displays the player if the url for a video published on YouTube or Vimeo is recorded in the field
In order to ensure the correct operation of all extensions, some files were added to the package, which added files to the structure of the web application and some dependencies. Consider them in more detail.
Package structure
After installing the X.Scaffolding NuGet package, the following elements will be added to your web application:

- Content \ global.css - contains the main styles for the web application ( Modern UI was taken as the basis)
- Content \ scaffolding.css - contains styles for individual controls generated by the ASP.NET MVC scaffolding system
- Scripts \ scaffolding.js - contains common for the entire web application scripts to initialize plug-ins
- Views \ System \ Login.cshtml - authorization page template
- Views \ _ViewStart.cshtml - page for automatic template setting for all views in the project
- favicon.ico - branded icon
Authorization module
The authorization module is made on the basis of the
template from the site bootsnipp.com
In addition to files added directly by the X.Scaffolding package, some other packages and related files are also added to the project. Consider them in more detail.
NuGet Plugin Packages
- X.CKEditor - WYSIWYG editor, for editing HTML (since the CKEditor team has not yet released the official NuGet package for version 4, I decided to do it myself)
- chosen.jquery - plugin for decorating beautiful and convenient drop-down lists with search. It is discussed in more detail in the article that was written by alizar.
- Bootstrap Datepicker - a plugin that allows you to add items to select dates in the style of Bootstrap
- Microsoft ASP.NET MVC 5 - since the library is primarily designed to extend the current version of MVC, a link was added to this version
- EntityFramework 6 - the same goes for the Entity Framework
- Windows Azure Storage - a set of libraries that make it easier to work with web applications hosted in the cloud
- Bootstrap 3 - I think you should not imagine this framework, especially since starting from Visual Studio 2013 the base project is created with the bootstrap package already connected
- PagedList.Mvc is a library that makes it easy to split lists into "pages." In addition, it includes styles and code for paging in the markup of templates.
- Microsoft jQuery Unobtrusive Validation - package for "unobtrusive" validation. You can read more about it in the article that Juty wrote .
Join now!

Anyone can either get acquainted with the source code of the library, and expand its capabilities.
Project source codes are available on
GitHub .
Nuget
You can install the package from the
NuGet repository:
Install-Package xscaffolding
DisclaimerI want to immediately warn you that since the library was created primarily for use in your own projects, there may be several things to consider when using it:
- Now the library is designed for using ASP.NET MVC 5 version and Entiy Framework 6 version in the project.
- When installing the package, a branded favicon is added to the web application (due to the fact that most of the package installations are now made for our own projects)
- When installing, a link to the WindowsAzure.Storage package is added to the web application, which may be superfluous for those who do not work with Windows Azure
However, the source code of the library is now open access. And besides, if there is enough interest in the library - I plan to create the X.Scaffolding.Core package, in which there will be no binding to the above packages and there will be no favicon.
UpdateSince the package in NuGet initially contained both the library and the styles of design, I decided to divide it into two parts.
- In X.Scaffolding.Core, I transferred the basic functionality (library itself and dependencies for ASP.NET MVC 5, CKEditor js-libraries, Bootstrap, etc.).
- In X.Scaffolding , a dependency on X.Scaffolding.Core, Entity Framework 6, Windows Azure Storage has been added, and Modern UI styling has been added.
Therefore, if you do not need extra css styles in the project, then you can use the
X.Scaffolding.Core package.