Thursday, June 30, 2011

Hot to add custom functionality to user interface form


One of common limitations of code generators is the inability for add custom functionality to automatically generated code, and if done, usually loss their integration with the generated code.

The  SFS Tools are totally different to other code generator  in this aspect, because allow a good integration between the generated code and the custom code.

In this tutorial we will add functionality to the user interface using the javascript framework: jquery ( ).

This is a ASP.NET MVC application, and ASP.NET MVC is highly dependent of javascript for add functionality. Learn the basics of jquery is minimal effort, and the benefit is great.

Columns not supported for now

For now there are some columns that are not supported.

XML Columns

In this case we see the example of the column “Instructions” of the “ProductModel” table in sample project of AdventureWorks Database.

Regenerate code in business rules project

the business rules layer project contains all functionality about CRUD operations resolved, so that whenever there are changes in the data structure is appropriate (and sometimes necessary) to regenerate all the code.

Just select the files “” and “” and right click and select “Run Custom Tool” from the context menu.



Wednesday, June 29, 2011

Convert a dropdown list to LookUp

We have seen how to convert a drop-down list to autocomplete. But in this case we focus on  LookUp.


With the SFS tools you can convert any relationship between entities (natural or custom) in a query to the catalog to select one entity. This is important and convenient when a simple "dropdownlist" is no longer useful to display a large amount of data. Moreover, in a Lookup can do searches as done in the same catalog that owns the relationship (reusable functionality).

Convert a drop down list to autocomplete

The effect o data incremental search is the best choice in relationships where data amount can be large, with SFS Tools this is done in a few minutes just setting a parameter.


Sunday, June 26, 2011

Regenerate the code of user interface layer

With SFS Tools, this task is to automatically generate the code of the user interface (Forms). Important: With the SFS Tools is possible generate and maintain the code continuously integrating the code of the programmer.

The task of regeneration of code can be very common in the life of the project.

Regular Expression validations


It's easy to add validation rules based on regular expressions, with SFS tools is even easier, because it automatically generates the necessary code only sets the rule as a custom property.

How to configure and extend an entity for code generation


Initially, all the code that is generated automatically in the solution is based on native entities Entity Framework, but you can create completely custom entities and configure the Entity Framework entities adding custom properties.

To this, we call: Model (and Entities ) Configuration.


Hiding fields


One of the simplest ways to make invisible or invisible attributes are certain fields in the model, which directly affects the generated code.

For this example use an entity "Contact."


  1. Build the sample application.
  2. Create the configuration file for code generation of the entity "Contact".

Friday, June 24, 2011

Customizing strings


With SFS Tools, all fields support localization, so the way to change is through resource files, or any other localization provider.

The automatic generation of the solution creates all the necessary resource files for each business object and other necessary for the module. All resource files in a folder and are easy to modify.


Build a sample application.


Changing text for each language.

  1. In the presentation project (ASP.NET MVC) of business module, open the "Resources" folder and see that each business entity there is a resource file.
  2. Select the file to customize the business object, in this case: "ProductResources.resx", right click and select "Copy" from the context menu and "Ctrl + v" paste in the same folder (which will create a file name: "Copy of ProductResources.resx").
    image   image
  3. Select the file "Copy of ProductResources.resx" and right click to select "Rename" from the context menu and rename it adding ".es-mx" (Or any other localization id) before the ". resx" . Now the name file is " "
  4. Open the file "" with double click and change the following texts:
    PRODUCTS_ADD_NEW”, “PRODUCTS_DETAILS”, “PRODUCTS_EDIT” and  “PRODUCTS_LIST”  used for the title of the forms in CRUD operations (create, read, update and delete).
    The fields ENTITY_PLURAL and ENTITY_SINGLE, are important because they are used for build the site map menu.
    You can change any other file, for this example change only 3: "NAME", "PRODUCTMODEL"  Relationship to one (Foreign Key) and "PRODUCTSTHISTORIES" (Relationship to many).
  5. Right click on the application "SFS.AdventureWorks.Web.Mvc" and select "Build" from the context menu.
    The application is compiling and generating the assemblies to be deposited in the bin folder of the web project shell (SFSdotNet.Framework.Web.Mvc).
  6. Run the application.
  7. Go to “lista de productos” (Sorry by language for this sample)
    image  image  image
    See how the grid column header "Name" has been changed to "Nombre" and the title of the form has changed to.
  8. Right click on the row with the Name: “” and select "Details" from the context menu.
    This will open the form details of the "Product", and you can see how the strings of the properties have changed.
    image  image 
    The effects of the localization are more that this, it is important to note that even with that all functionality related with "business entity" is localized and integrated automatically.
    For example, if you return to the "Product List" and click on the link "Abrir búsqueda avanzada", then "Agregar filtro" then you can see that also in the filter engine has the effect of localization.
    image  image

Now, how does this? Es implementando los atributos de localización en el modelo. It is implementing the localization attributes in the model.


A good practice recommended by Microsoft but that can cost many hours if not using an automation tool.

Setting the language of the application.

In this example we have localized in Spanish - Mexico (es-mx), but you can do to the language you require and you should consider two options: a  specific localization language or can be configured automatically in the Shell project's web.config file from SFSdotNet.Framework.Web.Mvc project

  • Using a specific language
    <globalization culture="es-mx" uiCulture="es-mx" requestEncoding="ISO-8859-1" responseEncoding="ISO-8859-1" fileEncoding="ISO-8859-1"/>
  • Using a automatic language
    <globalization culture="Auto" uiCulture="Auto" requestEncoding="ISO-8859-1" responseEncoding="ISO-8859-1" fileEncoding="ISO-8859-1"/>


All text in a solution with SFS Tools are fully localized via  resource files in one place: the "Resources" folder.  Its complexity is reduced to copy, paste and translate.

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: