Universal Providers enable Cloud-based Storage in RIA Services

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

To use SQL Azure cloud storage with a RIA Services application, you must install the ASP.NET Universal Providers that add support for Session, Membership, Roles and Profile in ASP.NET 4. These providers support all editions of SQL Server 2005 and later, including SQL Azure and SQL Server Compact editions. The Universal Providers are installed with Visual Studio 2012, but need to be installed separately using the Nuget Package Manager for relevant projects in Visual Studio 2010. They are contained in the System.Web.Provider.dll and RIA Services applications that use them must make reference to this assembly.

Other than supporting the additional storage options, the providers work just like the existing SQL-based providers. Using the Universal "Default Profile Providers" consists of setting the right connection strings in the application. By default, the connection string is set to use a SQL Server Express database, as in the following example.

<configuration>
   <connectionStrings>
      <add name="DefaultConnection" 
      connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnet.mdf;Initial Catalog=aspnet;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
   </connectionStrings>
   <system.web>
      <profile defaultProvider="DefaultProfileProvider" >
         <providers>
            <add name="DefaultProfileProvider" 
         type="System.Web.Providers.DefaultProfileProvider" 
   connectionStringName="DefaultConnection" 
applicationName="/"/>
         </providers>
      </profile>
      <membership defaultProvider="DefaultMembershipProvider">
         <providers>
            <add name="DefaultMembershipProvider" 
            type="System.Web.Providers.DefaultMembershipProvider" 
            connectionStringName="DefaultConnection" 
            enablePasswordRetrieval="false" 
            enablePasswordReset="true" 
            requiresQuestionAndAnswer="false" 
requiresUniqueEmail="false"
   maxInvalidPasswordAttempts="5" 
      minRequiredPasswordLength="6" 
minRequiredNonalphanumericCharacters="0" 
passwordAttemptWindow="10"
   applicationName="/" />
         </providers>
      </membership>
      <roleManager defaultProvider="DefaultRoleProvider">
         <providers>
      <add name="DefaultRoleProvider" 
            type="System.Web.Providers.DefaultRoleProvider"
connectionStringName="DefaultConnection" 
applicationName="/" />
         </providers>
      </roleManager>
      <sessionState mode="Custom" customProvider="DefaultSessionProvider">
         <providers>
            <add name="DefaultSessionProvider" 
         type="System.Web.Providers.DefaultSessionStateProvider" 
         connectionStringName="DefaultConnection" 
      applicationName="/"/>
         </providers>
      </sessionState>
   </system.web>
</configuration>

If you want to use SQL Azure, change the connection string as in this example, which has been wrapped for readability.

<connectionStrings>
   <add name="Sql_Azure"
      connectionString="data source=myDNSName;
      Initial Catalog=myDatabase;
      User ID=myUserName;
      Password=myPassword;
      Encrypt=true;
      Trusted_Connection=false;
      MultipleActiveResultSets=True" 
      providerName="System.Data.SqlClient"/>
<connectionStrings>

No code changes are required in addition to these changes in the configuration strings.

Nuget Package Manager in Visual Studio 2010

To install the Universal Providers in an application being developed with Visual Studio 2010, right-click on the References folder of the client application in Solution Explorer and select the Manage NuGet Packages option. Find the Microsoft ASP.NET Universal Providers package, select it, and then click on the Install button that appears. Confirm that a reference has been provided to the System.Web.Provider assembly.