Thursday, June 23, 2011

Create a solution with SFS tools and Microsoft Visual Studio 2010

This post is a details abot this other introduction of SFS Tutorial Tools.


  1. Microsoft Visual Studio 2010 and Microsoft Visual Studio 2010 SP1
  2. ASP.NET MVC 3
  3. Database sample  “AdventureWorks” or any other.
  4. Install Nuget (optional)

Detailed Step by Step Guide

Install SFS VS Add-in

  1. Download and install the latest version of SFS VS Addin

Create a solution

  1. Start Microsoft Visual Studio 2010 and create a blank solution (in the short path like “c:\Projects” o “d:\Projects” by example).
  2. In the solution explorer, right click on the solution and select “Enable SFS in solution” on context menu.
  3. In the solution explorer right click on the solution and select “Add / Create Application Module”, and write the namespace of project in the field “Namespace”: SFS.AdventureWorks (for this sample) and right click in then  “Add” button.
    image  image
    please wait… this can take several minutes.
  4. Select “Discard” in conflict window that appears at the end of the process, after select “Reload”.
    image  image
    See and know the solution structure that was automatically created:

Create a data model

  1. In the project SFS.AdventureWorks.BusinessObjects.EF4 delete the next two files: ModuleNameModel.edmx y ModuleNameModel.sfsedmx and rename the folder ModuleNameModel to “SFSAdventureWorksModel”.
  2. Click in the icon “Show all files” and include two files: ”SFSAdventureWorksModel.edmx” and “SFSAdventureWorksModel.sfsedmx” with right clickand select “Inlcude in project”.
     image  image
  3. Ricght click in  “SFSAdventureWorksModel.edmx” and select “Properties” and clear the flield “Custom Tool”.
    image  image
  4. Open the file App.Config and change the value of conection string of the data base and save the changes:
    ( in my case, the database name is AdventureWorks, and the user is “sfsdev” and the password is “sfsdev” )
    <?xml version="1.0" encoding="utf-8"?>
    <add name="SFSAdventureWorksContext" connectionString="metadata=res://SFS.AdventureWorks.BusinessObjects.EF4/SFSAdventureWorksModel.csdl|res://SFS.AdventureWorks.BusinessObjects.EF4/SFSAdventureWorksModel.ssdl|res://SFS.AdventureWorks.BusinessObjects.EF4/SFSAdventureWorksModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(local);Initial Catalog=[Database];Persist Security Info=True;User ID=[username];Password=[password];MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />

  5. Make double click in SFSAdventureWorksModel.edmx file and open design mode of Entity Framework diagram. Right click on the document and select “Update model from database…

  6. In the tab “Add”  select the root of node “Tables” (But unselect  AWBuildVersion, DatabaseLogErrorLog y sysdiagrams) and select “Pluralize or singularize generated object names” (But unselect Include foreign key columns in the model) and make click in “Finish”.
    Save the changes. Click in “Save” after the end  of the process.

  7. Right click in the file “SFSAdventureWorksModel.edmx” in the solution explorer and select “Create Entity Framework Model” of context menu.
    See the file “SFSAdventureWorksModel.sfsedmx” now contains a new structure in Entity Framework model based.

Generate the code of all layers

  1. Generate the code of the business objects layer, right click and select “Run custom tool” in each *.tt file.
    image  image

  2. Generate the code in the EF4 Layer, right click and “Run Custom Tool” in the file
  3. Generate the code of EFPococAdapter layer
    image  image

  4. Generate the code of the Business Rules layer

  5. Generate the code of the user interface layer

  6. Include in the project all files generated in the next folders: “Controllers”, “Models”, “Views” and  “Resources”. Select and right click and select “Include in project” option.

  7. The resources files should also be included and then generate your classes with right click  and select “Run custom Tool

Create a Framework Database

  1. Create a database for FSS Framework and run the script that creates the objects in this example creates a database called SFS_Database
    image  image
  2. Create a user in MS SQL Server instance and assign it as the owner of the database SFS_Database.(Ex.: username: sfsdev, password: sfsdev)

Change the connection strings to the database

  1. In the project SFS.AdventureWorks.Web.Mvc, open the file SFSAdventureWorks.config and change the database name, the user and password.

  2. Make the same in the project SFSdotNet.Framework.My.Web.Mvc (The file SFSdotNetFrameworkMy.config) and SFSdotNet.Framework.Security.Web.Mvc (The file SFSdotNetFrameworkSecurity.config), pointing to the Framework database (SFS_Database) and using the credentials of the user previously created (Example, username: sfsdev, password: sfsdev).

Compile and run the application

  1. Compile the projects of the three modules, right click select the three projects (SFS.AdventureWorks.Web.Mvc, SFSdotNet.Framework.Security.Web.Mvc and SFSdotNet.Framework.My.Web.Mvc) and select “Build” from context menu.
  2. Set the project SFSdotNet.Framework.Web.Mvc as startup project and run the application without inspection, as seen in the pictures below.
    image  image
    Notes that after identifying the default credentials (user: emir.trevino, password: pass.word1) does not see any menu in the navigation tree.
  3. Back to solution in Microsoft Visual Studio and change the value in the option “AutoInjectPermissionsOnStartup” from “false” to “true” in the web.config file of project:  SFSdotNet.Framework.Web.Mvc and save the changes.
    image  image
  4. Return to the browser window and refreshes the screen of the application. Wait a few seconds, can be minutes, be patient! Being injected permits and business objects in the database Framework (SFS_Database) once the page loads You must return the value of "AutoInjectPermissionsOnStartup" to "false" is important!.
  5. Now you can see the menu (if necessary logs and re-enter), in the "catalog" click on the option "PRODUCTS" and see its functionality.
    image image  image

Done! the application is completed in this first phase, now comes the most important, complete the application in all next features, follow the tutorials.


With the SFS tools for Microsoft Visual Studio you can build from start to finish a functional solution with a many features and a robust architecture.

Next steps

Check the tutorials to see how to make other programming tasks tocomplete this application.

The SFS tools help does not end here, the most important part is how to add special functionality, business rules, configuration screens, validation, among other things.

Follow the tutorials:

No comments:

Post a Comment