- Microsoft Visual Studio 2010 and Microsoft Visual Studio 2010 SP1
- ASP.NET MVC 3
- Database sample “AdventureWorks” or any other.
- Install Nuget (optional)
Detailed Step by Step Guide
Install SFS VS Add-in
- Download and install the latest version of SFS VS Addin
Create a solution
- Start Microsoft Visual Studio 2010 and create a blank solution (in the short path like “c:\Projects” o “d:\Projects” by example).
- In the solution explorer, right click on the solution and select “Enable SFS in solution” on context menu.
- 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.
please wait… this can take several minutes.
- Select “Discard” in conflict window that appears at the end of the process, after select “Reload”.
See and know the solution structure that was automatically created:
Create a data model
- In the project SFS.AdventureWorks.BusinessObjects.EF4 delete the next two files: ModuleNameModel.edmx y ModuleNameModel.sfsedmx and rename the folder ModuleNameModel to “SFSAdventureWorksModel”.
- Click in the icon “Show all files” and include two files: ”SFSAdventureWorksModel.edmx” and “SFSAdventureWorksModel.sfsedmx” with right clickand select “Inlcude in project”.
- Ricght click in “SFSAdventureWorksModel.edmx” and select “Properties” and clear the flield “Custom Tool”.
- 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="Data Source=(local);Initial Catalog=[Database];Persist Security Info=True;User ID=[username];Password=[password];MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
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…”
- In the tab “Add” select the root of node “Tables” (But unselect AWBuildVersion, DatabaseLog, ErrorLog 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.
- 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
- Generate the code of the business objects layer, right click and select “Run custom tool” in each *.tt file.
- Generate the code in the EF4 Layer, right click and “Run Custom Tool” in the Model1.Context.tt file
- Generate the code of EFPococAdapter layer
- Generate the code of the Business Rules layer
- Generate the code of the user interface layer
- 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.
- The resources files should also be included and then generate your classes with right click and select “Run custom Tool”
Create a Framework Database
- Create a database for FSS Framework and run the script that creates the objects in this example creates a database called SFS_Database
- 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
- In the project SFS.AdventureWorks.Web.Mvc, open the file SFSAdventureWorks.config and change the database name, the user and password.
- 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
- 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.
- Set the project SFSdotNet.Framework.Web.Mvc as startup project and run the application without inspection, as seen in the pictures below.
Notes that after identifying the default credentials (user: emir.trevino, password: pass.word1) does not see any menu in the navigation tree.
- 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.
- 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!.
- Now you can see the menu (if necessary logs and re-enter), in the "catalog" click on the option "PRODUCTS" and see its functionality.
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.
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: http://en.sfsdotnet.com/tools/docs/tutorials