/// <summary>A one time method that can be used to create the tables required for token caching in a Sql server database</summary>
        /// <param name="sqlTokenCacheOptions">The SQL token cache options containing the connection string to the Sql Server database.</param>
        /// <remarks>In production scenarios, the database  will most probably be already present.</remarks>
        public static void CreateTokenCachingTablesInSqlDatabase(MsalSqlTokenCacheOptions sqlTokenCacheOptions)
        {
            var tokenCacheDbContextBuilder = new DbContextOptionsBuilder <TokenCacheDbContext>();

            tokenCacheDbContextBuilder.UseSqlServer(sqlTokenCacheOptions.SqlConnectionString);

            var tokenCacheDbContextForCreation = new TokenCacheDbContext(tokenCacheDbContextBuilder.Options);

            tokenCacheDbContextForCreation.Database.EnsureCreated();
        }
 public MsalSqlTokenCacheProvider(IHttpContextAccessor httpContextAccessor, TokenCacheDbContext tokenCacheDbContext, IOptions <AzureADOptions> azureAdOptionsAccessor, IDataProtectionProvider protectionProvider) :
     base(azureAdOptionsAccessor, httpContextAccessor)
 {
     _dataProtector = protectionProvider.CreateProtector("MSAL");
     _tokenCacheDb  = tokenCacheDbContext;
 }
 /// <summary>Initializes a new instance of the <see cref="MsalAppSqlTokenCacheProvider"/> class.</summary>
 /// <param name="tokenCacheDbContext">The token cache database context.</param>
 /// <param name="azureAdOptionsAccessor">The azure ad options accessor.</param>
 /// <param name="protectionProvider">The protection provider.</param>
 /// <exception cref="ArgumentNullException">
 /// protectionProvider - The app token cache needs an {nameof(IDataProtectionProvider)} to operate. Please use 'serviceCollection.AddDataProtection();' to add the data protection provider to the service collection
 /// or
 /// protectionProvider - The app token cache needs the '{nameof(AzureADOptions)}' section in configuration, populated with clientId to initialize.
 /// </exception>
 public MsalAppSqlTokenCacheProvider(IHttpContextAccessor httpContextAccessor, TokenCacheDbContext tokenCacheDbContext, IOptions <AzureADOptions> azureAdOptionsAccessor, IDataProtectionProvider protectionProvider)
     : base(httpContextAccessor, tokenCacheDbContext, azureAdOptionsAccessor, protectionProvider)
 {
 }