DevExpress MVVM Framework. Scaffolding Wizard: new UI templates, features and tutorials in 14.2.

WPF Team Blog
05 March 2015

Building a CRUD application from scratch can easily become a time-consuming exercise in tedium. Thankfully, most data-bound applications implement a common set of UI and architectural patterns. With the DevExpress Scaffolding Wizard, with only a few clicks you can build a functional application with a well-organized and extendable MVVM structure. Tweak the view layouts and add some app specific functionality — and you’re done.

Since version 13.1, we’ve been improving the Scaffolding Wizard to add new features for coverage of the maximum number of out-of-the-box scenarios and support for many more capabilities to extend scaffolded applications.

The 14.2 release includes a great number of new Scaffolding Wizard features. Let’s overview some of what’s been added.

We previously presented two complex demos: the Outlook Inspired App with a MS Outlook GUI:

InspOutlook

and the Touch-Enabled Hybrid App, designed for traditional desktop and touch-enabled devices alike.

HApp

These demos are based on code generated by the Scaffolding Wizard featuring several views (approximately twenty), custom logic and functionality. In the process of originally implementing these demos, we found the Scaffolding Wizard’s capabilities proved insufficient alone. This motivated us to significantly improve the Scaffolding Wizards in version 14.2.

The result is that most of the functionality of these demos can be simply generated by running a wizard. We’re eager to share some of our experience creating robust applications using code generated by the Scaffolding Wizard as a starting point.

New UI MDI View templates

Our first step was to develop two new templates for the Outlook Inspired and Hybrid UI apps, embodying our vision of the UI patterns which this class of applications should be built. You can follow along with these steps using the same templates and the Northwind Entity Framework model:

InspOutlook_scaff

HApp_scaff

One great thing you’ll notice is that all our templates (Tabbed, Outlook Inspired and Hybrid) generate exactly the same Data Model and View Model code. This means you can easily move code and logic (excluding views) to separate assemblies. You could choose to publish two versions of your app: one for the traditional desktop and another for touch-enabled devices.

We rewrote the scaffolding code generators so most scenarios are supported out-of-the-box or with minimal effort.

Asynchronous data loading

How long a data request to the server will take to complete depends on several factors: the size of the database, the database server’s performance, available bandwidth, etc. If you’re using Entity Framework Code First, you may also have noticed the first DbContext initialization takes considerable time.

In version 14.2, scaffolded applications now make use of a separate thread to query and load data. The loaded records are then transferred to the main thread and displayed in a grid control or some other data-bound control displaying the collections of entities.

AsynchronousDataLoading

Support of the projections mechanism

The scaffolding is only aware of the data model, and knows nothing about how many records are stored in a table or the efficiency of loading these records from the server. That’s why the Scaffolding Wizard generates general code that will work in any scenario. This means that manual optimizations may be required. Scaffolded code provides extension points which you can use to customize the default data loading mechanism and solve for any performance issues.

Along with the simple scenario where a lot of heavy objects are requested over a narrow channel, we’ll need to be aware of a less glaring problem.

Entity Framework’s Navigation Properties are loaded on demand. If you have a grid column databound to a nested property on a navigation property (for instance, OrderItem.Order.Date), a separate request to the database to load the navigation property will be performed on each record. This may affect the responsiveness of the grid while scrolling the records.

All these issues can be resolved with a few lines of codes using projections. Despite the intricate name, projections are nothing more than the well-known LINQ Data transformations.

Here’s a tutorial demonstrating how to use projections to improve performance and address other concerns: How To Use Projections to Create Custom Queries and Optimize Performance

If you’re familiar with our grids for the desktop (XtraGrid, DXGrid for WPF), you may be wondering whether it’s possible to use our Instant Feedback mode to solve these performance problems in the most difficult cases (100,000+ heavy objects in the database)? The short answer is yes.

We’ll soon have direct support for Instant Feedback mode in Scaffolding and tell you how to easily switch your collection views to display a collection of objects using Instant Feedback without any UI changes (xaml).

IDataErrorInfo support out of the box

If your entity supports the IDataErrorInfo interface, validation errors will be shown in the UI and invalid entities won’t be saved to the database until the errors are resolved.

IDataErrorInfo

New commands

We added some new commands to simplify working with scaffolded application as an end-user:

  • Save All – save changes in open detail edit forms
  • Save and New – save changes to the current detail edit form, create a new record and open is edit form
  • Save and Close - save changes in the current detail edit form and close it.
  • Reset Changes - cancel all changes

NewCommands

NewCommands_HA

New tutorials

Our Building Outlook-Inspired UI Application tutorial describes how to create a simplified version of our complex demos, with details descriptions of the main ideas and approaches of the original demos. Though this tutorial is quite long (11 steps), each step can be pursued separately to build an independent piece of functionality.

We have a new tutorial overviewing the projections mechanism: How To Use Projections to Create Custom Queries and Optimize Performance

To learn how to create an application bound to WCF see How to: Create an Application Bound to WCF Data Service.

We have also updated the existing tutorials, to illustrate the newly introduced features.

EF 5 is no longer supported

As of version 14.2, the Scaffolding Wizard no longer supports Entity Framework 5. If you have an existing Entity Framework 5 model, you will need to upgrade it to Entity Framework 6 before making use of the Scaffolding Wizard.

EFVersionError

Note that MS Visual Studio 2012 uses Entity Framework 5 to generate database-first models (the ADO.NET Entity Data Model project item template). So if you use Visual Studio 2012, be sure to upgrade your entity model before using the Scaffolding Wizard.

We’re curious to hear your feedback on how you’re using scaffolding and what features or guides you’d like to see in the future.

11 comment(s)
Nate Laff
Nate Laff

Will something like this come to Winforms too? On the Winforms side there seems to be the new push from DX for ... what was it... MVPVM?

5 March, 2015
Geert Depickere
Geert Depickere

Blogpost is under the WPF and Silverlight header, but this is probably WPF only?

5 March, 2015
Michael Ch (DevExpress Support)
Michael Ch (DevExpress Support)

Hello,

@Nate: Certainly, we have plans to improve and complete WinForms MVPVM features in a further release. Our final goal in this regard is to provide the capability to scaffold the Outlook or Hybrid Application with writing additional code as less as possible.

@Geert: Right, Scaffolding Wizard isn't available for Silverlight. At present, Silverlight's future is unclear, and we decided to put the Silverlight direction into maintenance mode. You can read about our position regarding this question in our blog: community.devexpress.com/.../silverlight-s-future-at-devexpress.aspx.

6 March, 2015
Ray Navasarkian (DevExpress)
Ray Navasarkian (DevExpress)

@Nate - - We’re planning to complete our WinForms MVPVM feature set in the v15.1 release cycle.

Our ultimate goal in this regard is to give you the ability to create Outlook or Hybrid MVVM applications via our Scaffolding Wizard without writing any code.

6 March, 2015
PAVEL UZORIN
PAVEL UZORIN

Hello, sorry for my english.

Please add Asynchronous data Saving and progress bar for saving completing.

If the ObjectSpace contains 50000 objects,  time saving it in the database becomes large,  it's too bad that it completely blocked the interface.

6 March, 2015
Michael Ch (DevExpress Support)
Michael Ch (DevExpress Support)

Hello Pavel,

At present, operations (like saving changes) are executed for a single item, so they are executed really fast in most cases. In any case, we agree that this functionality can be useful in certain scenarios (for example, if you save files to your database). We will take this scenario into account when extending our wizard. 

Thanks,

Michael

12 March, 2015
NHIF
NHIF

Editing parent/child or master/detail is not properly done.

usually we want to be able to edit a record such as order/ order details all in one view. The order should be in form view on the upper part and order details on the grid view. The grid view should allow crud operations in place.

The save transaction should be atomic.

Is there a way where we van customize wizard generated application to this?. Any example ?

Thank you.

22 March, 2015
Michael Ch (DevExpress Support)
Michael Ch (DevExpress Support)

Hello @NHIF,

I believe that it's possible to customize a scaffolded application in this way. Please contact our support team by submitting a ticket to our SC (you can do this here: www.devexpress.com/.../Create) and provide more details about the behavior you wish to implement. We will be happy to assist you.

Thanks,

Michael

23 March, 2015
DAVID NYAOSO
DAVID NYAOSO

Just like @NHIF, I will appreciate an example

14 December, 2016
Andrei Semianenka
Andrei Semianenka

Are there any chances that WPF Scaffolding Wizard will support Virtual Sources some day?

community.devexpress.com/.../wpf-data-grid-virtual-sources-v18-1.aspx

I'm working with REST service, and was able to scaffold these views by my models, but cannot hook into fetching the data, to populate it from REST API instead of database.

10 July, 2018
Alex Chuev (DevExpress)
Alex Chuev (DevExpress)

Andrei,

We have no plans for this at the moment. If you are working with a REST service, it will be necessary to write your application without Scaffolding Wizards.

Thanks,

Alex

10 July, 2018

Please login or register to post comments.