1. Open Profiles.xml file  and add the following xml elements at the very end, before </Profiles> tag and save the file

  2. <Profile name="Test-Profile-Resource-BaseClass-Child-Collection-IncludeOnly">
    <Resource name="School">
    <ReadContentType memberSelection="IncludeOnly">
    <Collection name="EducationOrganizationAddresses" memberSelection="IncludeOnly">
    <Property name="City" />
    <Property name="StateAbbreviationType" />
    <Property name="PostalCode" />
    </Collection>
    </ReadContentType>
    <WriteContentType memberSelection="IncludeOnly">
    <Collection name="EducationOrganizationAddresses" memberSelection="IncludeOnly">
    <Property name="Latitude" />
    <Property name="Longitude" />
    </Collection>
    </WriteContentType>
    </Resource>
    </Profile>

  3. Run t4 template generation to generate the profiles.  The way you do is by clicking on the Build menu and clicking 'Transform All T4 Templates'.  This should successfully generate the Profiles.

  4. You can run the Security Configuration Tool in debug/new instance and add an existing application to the vendor that you created previously.  
  5. Click on the Profiles and you should see the 'Test-Profile-Resource-BaseClass-Child-Collection-IncludeOnly'


------------------------------------------------------------Second way of doing the lab - for reference purpose only ------------------------------------------------------------------------------------------------

    Close Visual Studio before starting the lab.  
  1. Install the template by downloading and launching the attached .vsix file.  https://techdocs.ed-fi.org/download/attachments/30638231/Ed-Fi-API-Profiles-Project-Template.vsix?api=v2   - Copy this link in a browser, it will ask you login to TechDocs if you have not done so.  
  2. Restart Visual Studio and open the Ed-Fi ODS / API Solution file.
  1. Add a new project to the solution by clicking File > Add > New Project...
  2. In the "Add New Project" dialog, find the "Ed-Fi API Profiles Project" entry at the bottom of the Visual C# section, as shown below.
  3. Enter the project name for the new project and click OK. The suggested naming convention for this type of project is something like "EdFi.Ods.Api.MyProfiles".

Generate the API Artifacts

To generate the API artifacts, initiate the T4 template code generation process using one of the following mechanisms:

  1. Build the project.
  2. From the Build menu, select "Transform All T4 Templates" (this will generate all artifacts for the entire solution).
  3. Select the T4 template files individually (or simultaneously using Ctrl+Click with your mouse), and then right click and choose Run Custom Tool.

At this point, your Solution Explorer should look something like this:

With the Profiles-specific code generated, it's time to integrate it with ASP.NET WebAPI framework.

Integrating Profiles into the ASP.NET WebAPI

  1.  Add the following interface to the file named Marker_EdFi_Ods_Api_Models_TestProfiles.cs at the root of the profile project that you created.
    namespace EdFi.Ods.Api.MyProfiles
    {
        public interface Marker_EdFi_Ods_Api_MyProfiles { }
    }

  2. Next, you will need to perform the following tasks in the EdFi.Ods.WebApi project (located in the solution under "Entry Points"):

    1. Add a reference to the Profiles project you constructed in the previous section.
    2. Add a custom OWIN startup class named MyProfilesSandboxStartup in the Startup folder:   

    using System.Web.Http;
    using Castle.MicroKernel.Registration;
    using EdFi.Ods.Api.MyProfiles;
    using EdFi.Ods.Api.Startup;
    using EdFi.Ods.WebApi.Startup;
    using Microsoft.Owin;
    using Owin;
      
    [assembly: OwinStartup("MyProfilesSandbox"typeof(MyProfilesSandboxStartup))]
      
    namespace EdFi.Ods.WebApi.Startup
    {
        public class MyProfilesSandboxStartup : SandboxStartupBase
        {
            public override void Configuration(IAppBuilder appBuilder)
            {
                base.Configuration(appBuilder);
      
                // Register additional controllers from the profiles
                Container.Register(
                    Classes.FromAssemblyContaining<Marker_EdFi_Ods_Api_MyProfiles>()
                           .BasedOn<ApiController>()
                           .LifestyleTransient());
            }
        }
    }

  3. Modify the Web.config file to use the new custom Startup class.

    <appSettings>
        <!-- The name of the OWIN startup class for this website -->
        <!--<add key="owin:appStartup" value="Sandbox" />-->
        
        <!-- Use this OWIN startup class to incorporate Profiles into the Sandbox (then add a project reference to Profiles project) -->
        <addkey="owin:appStartup"value="MyProfilesSandbox"/>
        ...



  4. Login to EdFi_Admin database and do the following....

    Select * from Profiles 


    You should see the above.  After you assign profiles to API Clients, you will see records in ProfileApplications table.  

  5. EdFi_Admin Database:  The tables that are related to Profiles are in the EdFi_Admin database

    image2015-9-3 19-33-12.png





  • No labels