AdventureWorks With WillFrame

In this Blog we want to illustrate some of the power of Willframe Framework in a complete example using the Adventure Works Database from Microsoft.

Learn in this page

  • Automated Export of database schema into an xml output
  • Automated code generation of entities for each table of the database
  • Automated web service layer code generation of the new entities
  • Example on how to use the generated code.
  • Example on how to use the web service.


The whole example can be uploaded from this link.

The Database can be downloaded from the Microsoft Pages. We recommand to download the release for SQL Server 2014 or newer.

Use Microsoft Visual Studio 2013 or newer to work with this project.


This Example containts three Libraries

  • AdventureWorksLib 

    contains the entity definition and the business logic. the entities are generated and stored in a sub directory named Entities.

  • AdventureWorksService 

    contains the interface for fully qualified service for the generated classes.

  • AdventureWorksBrowser 

    This project illustrates the usage of the generated code and contains a WinForms Dialog that browses all the contents of the tables using there dependences (foreign constraints).

  • build.xml 

    This is a MS Build Script, that automates all the build and generating actions. Additional for each action there is a command line availiable, that can be executed directly.Before you use this script please make sure, that the database connection string in the build skript is configured correct and can access the adventure works database. Edit the file build.xml and modify the following clause:

    Following actions and commands can be executed using this build script:

    1. Schema Export (command line build-schemaexport.cmd)This commad executes the command “DbmsCmd.exe”, what can export a database in an xml file. Following command will be executed by calling this action:

      The exported database schema definition is stored in the file “AdventureWorksLib\Schema\AdventureWorks-schema.xml”. Please open this file and study its contents. The File contains all components of the database definition (Tables, Columns, Views, Procedures, Triggers, Constraints, Foreign Keys)

    2. Entitiy Generation (command line build-entity.cmd)Now the upove xml file contains alot of information, on how an entity looks like. The command DbmsEntityTool.exe reads this xml file and generates out of it entities for each table in the calling the command line build-entity.cmd the following command line will be executed

      The tool does not only creates entities, but also there web service derivates. The entities are stored in the folder AdventureWorksLib\Entities. The web service derivates of the entities are stored in the folder AdventureWorksService\Entities. Please open this folders and study the generated classes. all the generated classes are documented and have detailed information about there properties. As example, if you look at the person class, you will figure out, whitch table it reflects and what column each property reflects.


    3. Compile Projects Folder (command line build.cmd)Now as we generated the entities and the web service, we can go and compile the whole stuff by executing the command build.cmd.
    4. Done.if no errors happen, we are done.
  • Execute AdventureWorksBrowser\bin\Debug\AdventureWorksBrowser.exe and enjoy the example.AdventureWorksBrowser
  • Adventure Web Service 

    To see the produced full qualified web service interface of the adventure works database goto to this link. You can create a new web service client and try to access the service.The following example code changes the middle name of the first person found over the web service.

    A web service client project is part of the adventure works example solution presented here. The project name is AdventureWorksServiceTest.

  • Database Schema Modifications 

    Now add some columns to a table or add a new tables and execute the upove commands build-schemaexport.cmd, build-entity.cmd and build.cmd after each other and you will see that database changes are automatically reflected in the source code.

  • Entity Check (command line build-entitycheck.cmd)This amazing command checks if the source code is up to date with the schema definitions. integrating this routine on the head of the compiling routine will prevent developers to continue work until the source is synchron with the database schema definition.
  • Notice 

    You are not forced to use the Adventure Works Database. Bind any database you want, you will get the same results with different tables. Try it using your Database.To do so, you must do the following steps:

    • Change the connection string in build.xml to the database you want to reflect
    • Remove all files in AdventureWorksLib\Schema
    • Remove all files in AdventureWorksLib\Entities
    • Remove all files in AdventureWorksService\Entities
    • execute after each other the commands build-schemaexport.cmd, build-entity.cmd
    • Open the projects AdventureWorksLib and AdventureWorksService and remove all files in the project sub folders Entities and readd the new generated files from same directories.
    • Now execute the command line build.cmd. this builds the projects with other database.
  • Comming Soon 

    Learn how to automatically upgrade database schema changes on target databases (as example customer databases).

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.