Index: src/FinkiChattery/FinkiChattery.Api/FinkiChattery.Api.csproj
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/FinkiChattery.Api.csproj	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Api/FinkiChattery.Api.csproj	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -8,4 +8,6 @@
     <PackageReference Include="FluentValidation" Version="9.5.4" />
     <PackageReference Include="FluentValidation.AspNetCore" Version="9.5.4" />
+    <PackageReference Include="Hangfire.AspNetCore" Version="1.7.25" />
+    <PackageReference Include="Hangfire.SqlServer" Version="1.7.25" />
     <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
     <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
@@ -23,4 +25,8 @@
   </ItemGroup>
 
+  <ItemGroup>
+    <Folder Include="Controllers\" />
+  </ItemGroup>
+
 
 </Project>
Index: src/FinkiChattery/FinkiChattery.Api/Server/AppSettings.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/Server/AppSettings.cs	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ 	(revision )
@@ -1,55 +1,0 @@
-﻿using Microsoft.Extensions.Configuration;
-using FinkiChattery.Api.Contracts.AppSettings;
-
-namespace FinkiChattery.Api.Services
-{
-    public class AppSettings
-    {
-        public AppSettings(IConfiguration configuration)
-        {
-            Configuration = configuration;
-        }
-
-        public IdentitySettings IdentitySettings
-        {
-            get
-            {
-                var identitySettings = new IdentitySettings();
-                Configuration.GetSection("app:identitySettings").Bind(identitySettings);
-                return identitySettings;
-            }
-        }
-
-        public EmailCredentialsSettings EmailCredentialsSettings
-        {
-            get
-            {
-                var emailSettings = new EmailCredentialsSettings();
-                Configuration.GetSection("app:emailSendingCredentials").Bind(emailSettings);
-                return emailSettings;
-            }
-        }
-
-        public CorsSettings CorsSettings
-        {
-            get
-            {
-                var corsSettings = new CorsSettings();
-                Configuration.GetSection("app:corsSettings").Bind(corsSettings);
-                return corsSettings;
-            }
-        }
-
-        public AwsStorageSettings AwsStorageSettings
-        {
-            get
-            {
-                var awsSettings = new AwsStorageSettings();
-                Configuration.GetSection("app:awsStorageSettings").Bind(awsSettings);
-                return awsSettings;
-            }
-        }
-
-        private IConfiguration Configuration { get; }
-    }
-}
Index: src/FinkiChattery/FinkiChattery.Api/Server/RegisterServices.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/Server/RegisterServices.cs	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ 	(revision )
@@ -1,117 +1,0 @@
-﻿using FinkiChattery.Api.Services;
-using FinkiChattery.Common.Mediator;
-using FinkiChattery.Common.Mediator.Interfaces;
-using FinkiChattery.Common.User;
-using FinkiChattery.Common.Validation;
-using FinkiChattery.Persistence.Context;
-using FinkiChattery.Persistence.Models;
-using MediatR;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace FinkiChattery.Api.Server
-{
-    public static class RegisterServices
-    {
-        public static void AddMediator(this IServiceCollection services)
-        {
-            services.AddScoped<IMediatorService, MediatorService>();
-            services.AddScoped<IEventService, EventService>();
-            services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
-
-            // TODO: REGISTER MEDIATOR HANDLERS WHEN WE CREATE FIRST COMMAND SMENI SO DOMAIN KLASA
-            services.AddMediatR(typeof(RegisterServices));
-        }
-
-        public static void AddSingletonServices(this IServiceCollection services)
-        {
-            services.AddSingleton<AppSettings, AppSettings>();
-        }
-
-        public static void AddIdentityService(this IServiceCollection services, IConfiguration configuration)
-        {
-            var appSettings = new AppSettings(configuration);
-
-            services.AddIdentity<ApplicationUser, ApplicationRole>(o =>
-            {
-                o.User.RequireUniqueEmail = true;
-            })
-            .AddEntityFrameworkStores<ApplicationDbContext>()
-            .AddDefaultTokenProviders();
-
-            services.AddAuthentication(options =>
-            {
-                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
-                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
-            }).AddJwtBearer(o =>
-            {
-                o.Authority = appSettings.IdentitySettings.Authority;
-                o.Audience = appSettings.IdentitySettings.Audience;
-                o.RequireHttpsMetadata = appSettings.IdentitySettings.RequireHttpsMetadata;
-            });
-
-            services.AddAuthorization();
-        }
-
-        public static void AddEmailService(this IServiceCollection services)
-        {
-            // TODO: Add email service
-            // services.AddScoped<IEmailService, EmailService>();
-        }
-
-        public static void AddCurrentUser(this IServiceCollection services)
-        {
-            services.AddScoped(x =>
-            {
-                var httpContext = x.GetRequiredService<IHttpContextAccessor>();
-                return CurrentUser.GetCurrentUser(httpContext);
-            });
-        }
-
-        public static void AddRepos(this IServiceCollection services)
-        {
-        }
-
-        public static void AddOriginUrlSettings(this IServiceCollection services)
-        {
-            // TODO: ADD ORIGIN URLS 
-            /*services.AddScoped<IOriginUrlSettings>(provider =>
-            {
-                var httpContextAccessor = provider.GetService<IHttpContextAccessor>();
-
-                string originUrl = string.Empty;
-                if (httpContextAccessor.HttpContext != null && httpContextAccessor.HttpContext.Request.Headers.TryGetValue("Origin", out StringValues headerValues))
-                {
-                    if (headerValues.FirstOrDefault() != null)
-                    {
-                        originUrl = headerValues.FirstOrDefault();
-                    }
-                }
-
-                return new OriginUrlSettings(originUrl);
-            });*/
-        }
-
-        public static void AddAwsClient(this IServiceCollection services, IConfiguration configuration)
-        {
-            // ADD AWS FOR MAILS AND S3 AND CDN
-            /*            var appSettings = new AppSettings(configuration);
-
-                        services.AddAWSService<IAmazonS3>();
-                        services.AddSingleton<IAmazonS3>(provider =>
-                        {
-                            return new AmazonS3Client(
-                                appSettings.AwsStorageSettings.AccessKey,
-                                appSettings.AwsStorageSettings.SecretKey,
-                                Amazon.RegionEndpoint.GetBySystemName(appSettings.AwsStorageSettings.StorageServerRegion));
-                        });
-                        services.AddScoped<IStorageService, AwsStorageService>();*/
-        }
-
-        // TODO: ADD HANGFIRE AND SCAFOLD DB IN HANGFIREDB
-    }
-
-}
Index: src/FinkiChattery/FinkiChattery.Api/Services/AppSettings.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/Services/AppSettings.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.Api/Services/AppSettings.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,55 @@
+﻿using Microsoft.Extensions.Configuration;
+using FinkiChattery.Api.Contracts.AppSettings;
+
+namespace FinkiChattery.Api.Services
+{
+    public class AppSettings
+    {
+        public AppSettings(IConfiguration configuration)
+        {
+            Configuration = configuration;
+        }
+
+        public IdentitySettings IdentitySettings
+        {
+            get
+            {
+                var identitySettings = new IdentitySettings();
+                Configuration.GetSection("app:identitySettings").Bind(identitySettings);
+                return identitySettings;
+            }
+        }
+
+        public EmailCredentialsSettings EmailCredentialsSettings
+        {
+            get
+            {
+                var emailSettings = new EmailCredentialsSettings();
+                Configuration.GetSection("app:emailSendingCredentials").Bind(emailSettings);
+                return emailSettings;
+            }
+        }
+
+        public CorsSettings CorsSettings
+        {
+            get
+            {
+                var corsSettings = new CorsSettings();
+                Configuration.GetSection("app:corsSettings").Bind(corsSettings);
+                return corsSettings;
+            }
+        }
+
+        public AwsStorageSettings AwsStorageSettings
+        {
+            get
+            {
+                var awsSettings = new AwsStorageSettings();
+                Configuration.GetSection("app:awsStorageSettings").Bind(awsSettings);
+                return awsSettings;
+            }
+        }
+
+        private IConfiguration Configuration { get; }
+    }
+}
Index: src/FinkiChattery/FinkiChattery.Api/Services/Hangfire/HangfireConfigurationExtensions.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/Services/Hangfire/HangfireConfigurationExtensions.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.Api/Services/Hangfire/HangfireConfigurationExtensions.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,17 @@
+﻿using Hangfire;
+using Newtonsoft.Json;
+
+namespace FinkiChattery.Api.Services
+{
+    public static class HangfireConfigurationExtensions
+    {
+        public static void UseMediatR(this IGlobalConfiguration configuration)
+        {
+            var jsonSettings = new JsonSerializerSettings
+            {
+                TypeNameHandling = TypeNameHandling.All
+            };
+            configuration.UseSerializerSettings(jsonSettings);
+        }
+    }
+}
Index: src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,137 @@
+﻿using FinkiChattery.Api.Services;
+using FinkiChattery.Common.Mediator;
+using FinkiChattery.Common.Mediator.Interfaces;
+using FinkiChattery.Common.User;
+using FinkiChattery.Common.Validation;
+using FinkiChattery.Persistence.Context;
+using FinkiChattery.Persistence.Models;
+using Hangfire;
+using Hangfire.SqlServer;
+using MediatR;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+
+namespace FinkiChattery.Api.Server
+{
+    public static class RegisterServices
+    {
+        public static void AddMediator(this IServiceCollection services)
+        {
+            services.AddScoped<IMediatorService, MediatorService>();
+            services.AddScoped<IEventService, EventService>();
+            services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
+
+            // TODO: REGISTER MEDIATOR HANDLERS WHEN WE CREATE FIRST COMMAND SMENI SO DOMAIN KLASA
+            services.AddMediatR(typeof(RegisterServices));
+        }
+
+        public static void AddHangfireService(this IServiceCollection services, IConfiguration configuration)
+        {
+            services.AddHangfire(x =>
+            {
+                x.UseSqlServerStorage(configuration.GetConnectionString("HangfireConnection"), new SqlServerStorageOptions
+                {
+                    CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
+                    SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
+                    QueuePollInterval = TimeSpan.Zero,
+                    UseRecommendedIsolationLevel = true,
+                    DisableGlobalLocks = true
+                });
+                x.UseMediatR();
+            });
+            services.AddHangfireServer();
+        }
+
+        public static void AddSingletonServices(this IServiceCollection services)
+        {
+            services.AddSingleton<AppSettings, AppSettings>();
+        }
+
+        public static void AddIdentityService(this IServiceCollection services, IConfiguration configuration)
+        {
+            var appSettings = new AppSettings(configuration);
+
+            services.AddIdentity<ApplicationUser, ApplicationRole>(o =>
+            {
+                o.User.RequireUniqueEmail = true;
+            })
+            .AddEntityFrameworkStores<ApplicationDbContext>()
+            .AddDefaultTokenProviders();
+
+            services.AddAuthentication(options =>
+            {
+                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
+                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
+            }).AddJwtBearer(o =>
+            {
+                o.Authority = appSettings.IdentitySettings.Authority;
+                o.Audience = appSettings.IdentitySettings.Audience;
+                o.RequireHttpsMetadata = appSettings.IdentitySettings.RequireHttpsMetadata;
+            });
+
+            services.AddAuthorization();
+        }
+
+        public static void AddEmailService(this IServiceCollection services)
+        {
+            // TODO: Add email service
+            // services.AddScoped<IEmailService, EmailService>();
+        }
+
+        public static void AddCurrentUser(this IServiceCollection services)
+        {
+            services.AddScoped(x =>
+            {
+                var httpContext = x.GetRequiredService<IHttpContextAccessor>();
+                return CurrentUser.GetCurrentUser(httpContext);
+            });
+        }
+
+        public static void AddRepos(this IServiceCollection services)
+        {
+        }
+
+        public static void AddOriginUrlSettings(this IServiceCollection services)
+        {
+            // TODO: ADD ORIGIN URLS 
+            /*services.AddScoped<IOriginUrlSettings>(provider =>
+            {
+                var httpContextAccessor = provider.GetService<IHttpContextAccessor>();
+
+                string originUrl = string.Empty;
+                if (httpContextAccessor.HttpContext != null && httpContextAccessor.HttpContext.Request.Headers.TryGetValue("Origin", out StringValues headerValues))
+                {
+                    if (headerValues.FirstOrDefault() != null)
+                    {
+                        originUrl = headerValues.FirstOrDefault();
+                    }
+                }
+
+                return new OriginUrlSettings(originUrl);
+            });*/
+        }
+
+        public static void AddAwsClient(this IServiceCollection services, IConfiguration configuration)
+        {
+            // ADD AWS FOR MAILS AND S3 AND CDN
+            /*            var appSettings = new AppSettings(configuration);
+
+                        services.AddAWSService<IAmazonS3>();
+                        services.AddSingleton<IAmazonS3>(provider =>
+                        {
+                            return new AmazonS3Client(
+                                appSettings.AwsStorageSettings.AccessKey,
+                                appSettings.AwsStorageSettings.SecretKey,
+                                Amazon.RegionEndpoint.GetBySystemName(appSettings.AwsStorageSettings.StorageServerRegion));
+                        });
+                        services.AddScoped<IStorageService, AwsStorageService>();*/
+        }
+
+        // TODO: ADD HANGFIRE AND SCAFOLD DB IN HANGFIREDB
+    }
+
+}
Index: src/FinkiChattery/FinkiChattery.Api/Startup.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/Startup.cs	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Api/Startup.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -3,4 +3,5 @@
 using FinkiChattery.Api.Services;
 using FinkiChattery.Persistence.Context;
+using Hangfire;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
@@ -34,4 +35,5 @@
             services.AddRepos();
             services.AddAwsClient(Configuration);
+            services.AddHangfireService(Configuration);
 
             services.AddDbContext<ApplicationDbContext>(options =>
@@ -72,4 +74,5 @@
             {
                 endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
+                endpoints.MapHangfireDashboard();
             });
         }
Index: src/FinkiChattery/FinkiChattery.Api/appsettings.Development.json
===================================================================
--- src/FinkiChattery/FinkiChattery.Api/appsettings.Development.json	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Api/appsettings.Development.json	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -31,5 +31,6 @@
   },
   "ConnectionStrings": {
-    "DefaultConnection": "data source=.;initial catalog=FinkiChattery;integrated security=True;application name=FinkiChattery Base App;Pooling=true;Min Pool Size=5;Max Pool Size=30;"
+    "DefaultConnection": "data source=.;initial catalog=FinkiChattery;integrated security=True;application name=FinkiChattery Base App;Pooling=true;Min Pool Size=5;Max Pool Size=30;",
+    "HangfireConnection": "data source=.;initial catalog=FinkiChatteryHangfire;integrated security=True;application name=FinkiChattery Hangfire App;Pooling=true;Min Pool Size=5;Max Pool Size=30;"
   }
 }
Index: src/FinkiChattery/FinkiChattery.Common/FinkiChattery.Common.csproj
===================================================================
--- src/FinkiChattery/FinkiChattery.Common/FinkiChattery.Common.csproj	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Common/FinkiChattery.Common.csproj	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -7,4 +7,5 @@
   <ItemGroup>
     <PackageReference Include="FluentValidation" Version="9.5.4" />
+    <PackageReference Include="Hangfire.Core" Version="1.7.25" />
     <PackageReference Include="MediatR" Version="9.0.0" />
     <PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
Index: src/FinkiChattery/FinkiChattery.Common/Mediator/EventService.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Common/Mediator/EventService.cs	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Common/Mediator/EventService.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -1,3 +1,5 @@
-﻿using FinkiChattery.Common.Mediator.Interfaces;
+﻿using FinkiChattery.Common.Mediator.Contracs;
+using FinkiChattery.Common.Mediator.Interfaces;
+using Hangfire;
 
 namespace FinkiChattery.Common.Mediator
@@ -5,4 +7,20 @@
     public class EventService : IEventService
     {
+        public EventService(IBackgroundJobClient backgroundJob)
+        {
+            BackgroundJob = backgroundJob;
+        }
+
+        public IBackgroundJobClient BackgroundJob { get; }
+
+        public void Enqueue(string jobName, IEvent request)
+        {
+            BackgroundJob.Enqueue<IMediatorService>(bridge => bridge.PublishAsync(jobName, request));
+        }
+
+        public void Enqueue(IEvent request)
+        {
+            BackgroundJob.Enqueue<IMediatorService>(bridge => bridge.PublishAsync(request));
+        }
     }
 }
Index: src/FinkiChattery/FinkiChattery.Common/Mediator/Interfaces/IEventService.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Common/Mediator/Interfaces/IEventService.cs	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Common/Mediator/Interfaces/IEventService.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -1,6 +1,11 @@
-﻿namespace FinkiChattery.Common.Mediator.Interfaces
+﻿using FinkiChattery.Common.Mediator.Contracs;
+
+namespace FinkiChattery.Common.Mediator.Interfaces
 {
     public interface IEventService
     {
+        void Enqueue(string jobName, IEvent request);
+
+        void Enqueue(IEvent request);
     }
 }
Index: src/FinkiChattery/FinkiChattery.Common/Mediator/Interfaces/IMediatorService.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Common/Mediator/Interfaces/IMediatorService.cs	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Common/Mediator/Interfaces/IMediatorService.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -10,4 +10,8 @@
 
         Task<TResponse> SendAsync<TResponse>(ICommand<TResponse> request);
+
+        Task PublishAsync<TNotification>(TNotification notification) where TNotification : IEvent;
+
+        Task PublishAsync<TNotification>(string jobName, TNotification notification) where TNotification : IEvent;
     }
 }
Index: src/FinkiChattery/FinkiChattery.Common/Mediator/MediatorService.cs
===================================================================
--- src/FinkiChattery/FinkiChattery.Common/Mediator/MediatorService.cs	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.Common/Mediator/MediatorService.cs	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -1,5 +1,6 @@
-﻿using MediatR;
-using FinkiChattery.Common.Mediator.Contracs;
+﻿using FinkiChattery.Common.Mediator.Contracs;
 using FinkiChattery.Common.Mediator.Interfaces;
+using MediatR;
+using System.ComponentModel;
 using System.Threading;
 using System.Threading.Tasks;
@@ -25,4 +26,15 @@
             return await mediator.Send(request);
         }
+
+        public async Task PublishAsync<TNotification>(TNotification notification) where TNotification : IEvent
+        {
+            await mediator.Publish(notification, default);
+        }
+
+        [DisplayName("{0}")]
+        public async Task PublishAsync<TNotification>(string jobName, TNotification notification) where TNotification : IEvent
+        {
+            await mediator.Publish(notification, default);
+        }
     }
 }
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/FinkiChattery.HangfireDatabase.sqlproj
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/FinkiChattery.HangfireDatabase.sqlproj	(revision f64836d38271a74922f929c333b322b2a94a76a4)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/FinkiChattery.HangfireDatabase.sqlproj	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -14,5 +14,5 @@
     <RootNamespace>FinkiChattery.HangfireDatabase</RootNamespace>
     <AssemblyName>FinkiChattery.HangfireDatabase</AssemblyName>
-    <ModelCollation>1033, CI</ModelCollation>
+    <ModelCollation>1033,CI</ModelCollation>
     <DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>
     <DeployToDatabase>True</DeployToDatabase>
@@ -23,4 +23,6 @@
     <IncludeCompositeObjects>True</IncludeCompositeObjects>
     <TargetDatabaseSet>True</TargetDatabaseSet>
+    <DefaultCollation>SQL_Latin1_General_CP1_CI_AS</DefaultCollation>
+    <DefaultFilegroup>PRIMARY</DefaultFilegroup>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -57,4 +59,21 @@
   <ItemGroup>
     <Folder Include="Properties" />
+    <Folder Include="HangFire\" />
+    <Folder Include="HangFire\Tables\" />
+    <Folder Include="Security\" />
+  </ItemGroup>
+  <ItemGroup>
+    <Build Include="HangFire\Tables\Schema.sql" />
+    <Build Include="HangFire\Tables\Job.sql" />
+    <Build Include="HangFire\Tables\State.sql" />
+    <Build Include="HangFire\Tables\JobParameter.sql" />
+    <Build Include="HangFire\Tables\JobQueue.sql" />
+    <Build Include="HangFire\Tables\Server.sql" />
+    <Build Include="HangFire\Tables\List.sql" />
+    <Build Include="HangFire\Tables\Set.sql" />
+    <Build Include="HangFire\Tables\Counter.sql" />
+    <Build Include="HangFire\Tables\Hash.sql" />
+    <Build Include="HangFire\Tables\AggregatedCounter.sql" />
+    <Build Include="Security\HangFire.sql" />
   </ItemGroup>
 </Project>
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/AggregatedCounter.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/AggregatedCounter.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/AggregatedCounter.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,12 @@
+﻿CREATE TABLE [HangFire].[AggregatedCounter] (
+    [Key]      NVARCHAR (100) NOT NULL,
+    [Value]    BIGINT         NOT NULL,
+    [ExpireAt] DATETIME       NULL,
+    CONSTRAINT [PK_HangFire_CounterAggregated] PRIMARY KEY CLUSTERED ([Key] ASC)
+);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_AggregatedCounter_ExpireAt]
+    ON [HangFire].[AggregatedCounter]([ExpireAt] ASC) WHERE ([ExpireAt] IS NOT NULL);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Counter.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Counter.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Counter.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,11 @@
+﻿CREATE TABLE [HangFire].[Counter] (
+    [Key]      NVARCHAR (100) NOT NULL,
+    [Value]    INT            NOT NULL,
+    [ExpireAt] DATETIME       NULL
+);
+
+
+GO
+CREATE CLUSTERED INDEX [CX_HangFire_Counter]
+    ON [HangFire].[Counter]([Key] ASC);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Hash.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Hash.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Hash.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,13 @@
+﻿CREATE TABLE [HangFire].[Hash] (
+    [Key]      NVARCHAR (100) NOT NULL,
+    [Field]    NVARCHAR (100) NOT NULL,
+    [Value]    NVARCHAR (MAX) NULL,
+    [ExpireAt] DATETIME2 (7)  NULL,
+    CONSTRAINT [PK_HangFire_Hash] PRIMARY KEY CLUSTERED ([Key] ASC, [Field] ASC)
+);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_Hash_ExpireAt]
+    ON [HangFire].[Hash]([ExpireAt] ASC) WHERE ([ExpireAt] IS NOT NULL);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Job.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Job.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Job.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,22 @@
+﻿CREATE TABLE [HangFire].[Job] (
+    [Id]             BIGINT         IDENTITY (1, 1) NOT NULL,
+    [StateId]        BIGINT         NULL,
+    [StateName]      NVARCHAR (20)  NULL,
+    [InvocationData] NVARCHAR (MAX) NOT NULL,
+    [Arguments]      NVARCHAR (MAX) NOT NULL,
+    [CreatedAt]      DATETIME       NOT NULL,
+    [ExpireAt]       DATETIME       NULL,
+    CONSTRAINT [PK_HangFire_Job] PRIMARY KEY CLUSTERED ([Id] ASC)
+);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_Job_StateName]
+    ON [HangFire].[Job]([StateName] ASC) WHERE ([StateName] IS NOT NULL);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_Job_ExpireAt]
+    ON [HangFire].[Job]([ExpireAt] ASC)
+    INCLUDE([StateName]) WHERE ([ExpireAt] IS NOT NULL);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/JobParameter.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/JobParameter.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/JobParameter.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,8 @@
+﻿CREATE TABLE [HangFire].[JobParameter] (
+    [JobId] BIGINT         NOT NULL,
+    [Name]  NVARCHAR (40)  NOT NULL,
+    [Value] NVARCHAR (MAX) NULL,
+    CONSTRAINT [PK_HangFire_JobParameter] PRIMARY KEY CLUSTERED ([JobId] ASC, [Name] ASC),
+    CONSTRAINT [FK_HangFire_JobParameter_Job] FOREIGN KEY ([JobId]) REFERENCES [HangFire].[Job] ([Id]) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/JobQueue.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/JobQueue.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/JobQueue.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,8 @@
+﻿CREATE TABLE [HangFire].[JobQueue] (
+    [Id]        BIGINT        IDENTITY (1, 1) NOT NULL,
+    [JobId]     BIGINT        NOT NULL,
+    [Queue]     NVARCHAR (50) NOT NULL,
+    [FetchedAt] DATETIME      NULL,
+    CONSTRAINT [PK_HangFire_JobQueue] PRIMARY KEY CLUSTERED ([Queue] ASC, [Id] ASC)
+);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/List.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/List.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/List.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,13 @@
+﻿CREATE TABLE [HangFire].[List] (
+    [Id]       BIGINT         IDENTITY (1, 1) NOT NULL,
+    [Key]      NVARCHAR (100) NOT NULL,
+    [Value]    NVARCHAR (MAX) NULL,
+    [ExpireAt] DATETIME       NULL,
+    CONSTRAINT [PK_HangFire_List] PRIMARY KEY CLUSTERED ([Key] ASC, [Id] ASC)
+);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_List_ExpireAt]
+    ON [HangFire].[List]([ExpireAt] ASC) WHERE ([ExpireAt] IS NOT NULL);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Schema.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Schema.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Schema.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,5 @@
+﻿CREATE TABLE [HangFire].[Schema] (
+    [Version] INT NOT NULL,
+    CONSTRAINT [PK_HangFire_Schema] PRIMARY KEY CLUSTERED ([Version] ASC)
+);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Server.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Server.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Server.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,12 @@
+﻿CREATE TABLE [HangFire].[Server] (
+    [Id]            NVARCHAR (200) NOT NULL,
+    [Data]          NVARCHAR (MAX) NULL,
+    [LastHeartbeat] DATETIME       NOT NULL,
+    CONSTRAINT [PK_HangFire_Server] PRIMARY KEY CLUSTERED ([Id] ASC)
+);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_Server_LastHeartbeat]
+    ON [HangFire].[Server]([LastHeartbeat] ASC);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Set.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Set.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/Set.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,18 @@
+﻿CREATE TABLE [HangFire].[Set] (
+    [Key]      NVARCHAR (100) NOT NULL,
+    [Score]    FLOAT (53)     NOT NULL,
+    [Value]    NVARCHAR (256) NOT NULL,
+    [ExpireAt] DATETIME       NULL,
+    CONSTRAINT [PK_HangFire_Set] PRIMARY KEY CLUSTERED ([Key] ASC, [Value] ASC)
+);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_Set_Score]
+    ON [HangFire].[Set]([Key] ASC, [Score] ASC);
+
+
+GO
+CREATE NONCLUSTERED INDEX [IX_HangFire_Set_ExpireAt]
+    ON [HangFire].[Set]([ExpireAt] ASC) WHERE ([ExpireAt] IS NOT NULL);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/State.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/State.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/HangFire/Tables/State.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,11 @@
+﻿CREATE TABLE [HangFire].[State] (
+    [Id]        BIGINT         IDENTITY (1, 1) NOT NULL,
+    [JobId]     BIGINT         NOT NULL,
+    [Name]      NVARCHAR (20)  NOT NULL,
+    [Reason]    NVARCHAR (100) NULL,
+    [CreatedAt] DATETIME       NOT NULL,
+    [Data]      NVARCHAR (MAX) NULL,
+    CONSTRAINT [PK_HangFire_State] PRIMARY KEY CLUSTERED ([JobId] ASC, [Id] ASC),
+    CONSTRAINT [FK_HangFire_State_Job] FOREIGN KEY ([JobId]) REFERENCES [HangFire].[Job] ([Id]) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
Index: src/FinkiChattery/FinkiChattery.HangfireDatabase/Security/HangFire.sql
===================================================================
--- src/FinkiChattery/FinkiChattery.HangfireDatabase/Security/HangFire.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
+++ src/FinkiChattery/FinkiChattery.HangfireDatabase/Security/HangFire.sql	(revision ad058b3b8cf9865d7448cadada7f739aebf7be2d)
@@ -0,0 +1,3 @@
+﻿CREATE SCHEMA [HangFire]
+    AUTHORIZATION [dbo];
+
