title: Data Seed failed in hosted project in linux server. Asp .net core 2.1
body: <p>I hosted my project in ubunto 18.4 version server.All configurations done after it's not working,in the browser it shows 503 error.</p>
  
  <p>when I try to manually execute .dll file it show some errors.</p>
  
  <blockquote>
    <p>Could not resolve a service of type 'SocialApp.API.Data.Seed' for the
    parameter 'seeder' of method 'Configure' on type
    'SocialApp.API.Startup'. ---> System.ArgumentNullException: Value
    cannot be null. Parameter name: connectionString</p>
  </blockquote>
  
  <p>here is the full error code</p>
  
  <pre><code>Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
        User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
  Application startup exception: System.Exception: Could not resolve a service of type 'SocialApp.API.Data.Seed' for the parameter 'seeder' of method 'Configure' on type 'SocialApp.API.Startup'. ---&gt; System.ArgumentNullException: Value cannot be null.
  Parameter name: connectionString
     at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
     at Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions.UseMySql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 mySqlOptionsAction)
     at SocialApp.API.Startup.&lt;ConfigureServices&gt;b__4_0(DbContextOptionsBuilder s) in D:\MProj\Asp.net-core\SocialApp\SocialApp.API\Startup.cs:line 44
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.&lt;&gt;c__DisplayClass1_0`2.&lt;AddDbContext&gt;b__0(IServiceProvider p, DbContextOptionsBuilder b)
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.&lt;&gt;c__DisplayClass10_0`1.&lt;AddCoreServices&gt;b__0(IServiceProvider p)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.&lt;&gt;c__DisplayClass1_0.&lt;RealizeService&gt;b__0(ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
     --- End of inner exception stack trace ---
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.&lt;&gt;c__DisplayClass4_0.&lt;Build&gt;b__0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
     at Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterBuilderStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.HostFilteringStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0(IApplicationBuilder app)
     at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
  crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
        Application startup exception
  System.Exception: Could not resolve a service of type 'SocialApp.API.Data.Seed' for the parameter 'seeder' of method 'Configure' on type 'SocialApp.API.Startup'. ---&gt; System.ArgumentNullException: Value cannot be null.
  Parameter name: connectionString
     at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
     at Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions.UseMySql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 mySqlOptionsAction)
     at SocialApp.API.Startup.&lt;ConfigureServices&gt;b__4_0(DbContextOptionsBuilder s) in D:\MProj\Asp.net-core\SocialApp\SocialApp.API\Startup.cs:line 44
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.&lt;&gt;c__DisplayClass1_0`2.&lt;AddDbContext&gt;b__0(IServiceProvider p, DbContextOptionsBuilder b)
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.&lt;&gt;c__DisplayClass10_0`1.&lt;AddCoreServices&gt;b__0(IServiceProvider p)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.&lt;&gt;c__DisplayClass1_0.&lt;RealizeService&gt;b__0(ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
     --- End of inner exception stack trace ---
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.&lt;&gt;c__DisplayClass4_0.&lt;Build&gt;b__0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
     at Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterBuilderStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.HostFilteringStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0(IApplicationBuilder app)
     at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
  
  Unhandled Exception: System.Exception: Could not resolve a service of type 'SocialApp.API.Data.Seed' for the parameter 'seeder' of method 'Configure' on type 'SocialApp.API.Startup'. ---&gt; System.ArgumentNullException: Value cannot be null.
  Parameter name: connectionString
     at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
     at Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions.UseMySql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 mySqlOptionsAction)
     at SocialApp.API.Startup.&lt;ConfigureServices&gt;b__4_0(DbContextOptionsBuilder s) in D:\MProj\Asp.net-core\SocialApp\SocialApp.API\Startup.cs:line 44
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.&lt;&gt;c__DisplayClass1_0`2.&lt;AddDbContext&gt;b__0(IServiceProvider p, DbContextOptionsBuilder b)
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
     at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.&lt;&gt;c__DisplayClass10_0`1.&lt;AddCoreServices&gt;b__0(IServiceProvider p)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.&lt;&gt;c__DisplayClass1_0.&lt;RealizeService&gt;b__0(ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
     --- End of inner exception stack trace ---
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.&lt;&gt;c__DisplayClass4_0.&lt;Build&gt;b__0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
     at Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterBuilderStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.HostFilteringStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0(IApplicationBuilder app)
     at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
     at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
     at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
     at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
     at SocialApp.API.Program.Main(String[] args) in D:\MProj\Asp.net-core\SocialApp\SocialApp.API\Program.cs:line 17
  Aborted (core dumped)
  </code></pre>
  
  <p>here is my startup class code</p>
  
  <pre><code>public class Startup
      {
          public Startup(IConfiguration configuration
         , IHostingEnvironment env)
          {
              _env = env;
              Configuration = configuration;
              var builder = new ConfigurationBuilder()
          .SetBasePath(env.ContentRootPath)
          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
          Configuration = builder.Build();
          }
  
  
      public IConfiguration Configuration { get; }
   public readonly IHostingEnvironment _env;
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddDbContext&lt;DataContext&gt;(s =&gt; s.UseMySql(Configuration.GetConnectionString("DefaultConnection"))
          .ConfigureWarnings(warnings =&gt; warnings.Ignore(CoreEventId.IncludeIgnoredWarning)));
  
          IdentityBuilder builder = services.AddIdentityCore&lt;User&gt;(opt =&gt;
          {
              opt.Password.RequireDigit = false;
              opt.Password.RequiredLength = 4;
              opt.Password.RequireNonAlphanumeric = false;
              opt.Password.RequireUppercase = false;
  
          });
  
          builder = new IdentityBuilder(builder.UserType, typeof(Role), builder.Services);
          builder.AddEntityFrameworkStores&lt;DataContext&gt;();
          builder.AddRoleValidator&lt;RoleValidator&lt;Role&gt;&gt;();
          builder.AddRoleManager&lt;RoleManager&lt;Role&gt;&gt;();
          builder.AddSignInManager&lt;SignInManager&lt;User&gt;&gt;();
  
  
  
          // services.AddAuthorization(options =&gt; {
          //     options.AddPolicy("RequireAdminRole", policy =&gt; policy.RequireRole("Admin"));
          //     options.AddPolicy("SuperAdminPhotoRole", policy =&gt; policy.RequireRole("SuperAdmin"));
          // });
  
          services.AddMvc(options =&gt;
          {
              var policy = new AuthorizationPolicyBuilder()
                  .RequireAuthenticatedUser()
                  .Build();
              options.Filters.Add(new AuthorizeFilter(policy));
          })
          .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
          .AddJsonOptions(opt =&gt;
          {
              opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
          });
          services.AddCors();
          services.AddAutoMapper();
          services.AddTransient&lt;Seed&gt;();
          services.AddScoped&lt;IAuthRepository, AuthRepository&gt;();
          services.AddScoped&lt;IDatingRepository, DatingRepository&gt;();
          services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
          .AddJwtBearer(options =&gt;
          {
              options.TokenValidationParameters = new TokenValidationParameters
              {
                  ValidateIssuerSigningKey = true,
                  IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII
                    .GetBytes(Configuration.GetSection("AppSettings:Token").Value)),
                  ValidateIssuer = false,
                  ValidateAudience = false
              };
          });
          services.AddScoped&lt;LogUserActivity&gt;();
  
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env, Seed seeder)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
  
              app.UseExceptionHandler(builder =&gt;
              {
                  builder.Run(async context =&gt;
                  {
                      context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
  
                      var error = context.Features.Get&lt;IExceptionHandlerFeature&gt;();
                      if (error != null)
                      {
                          context.Response.AddApplicationError(error.Error.Message);
                          await context.Response.WriteAsync(error.Error.Message);
                      }
                  });
              });
  
              // app.UseHsts();
          }
  
          // app.UseHttpsRedirection();
          seeder.SeedUsers();
          app.UseCors(x =&gt; x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
          app.UseAuthentication();
          app.UseDefaultFiles();
          app.UseStaticFiles();
          app.UseMvc(routes =&gt;
          {
              routes.MapSpaFallbackRoute(
                  name: "spa-fallback",
                  defaults: new { controller = "FallBack", action = "Index" }
              );
          });
      }
  }
  </code></pre>
  
  <p>Here is Seed class code</p>
  
  <pre><code>public class Seed
      {
  
          private readonly UserManager&lt;User&gt; _userManager;
          private readonly RoleManager&lt;Role&gt; _roleManager;
  
          public Seed(UserManager&lt;User&gt; userManager, RoleManager&lt;Role&gt; roleManager)
          {
              _roleManager = roleManager;
              _userManager = userManager;
          }
  
          public async void SeedUsers()
          {
              if (_userManager.Users.Any())
              {
                  var userData = System.IO.File.ReadAllText("Data/UserSeedData.json");
                  var users = JsonConvert.DeserializeObject&lt;List&lt;User&gt;&gt;(userData);
  
                  var roles = new List&lt;Role&gt;
                  {
                      new Role{ Name="Student"},
                      new Role{ Name="Professor"},
                      new Role{ Name="Admin"},
                      new Role{ Name="SuperAdmin"},
                      new Role{ Name="Sponsor"}
                  };
  
                  foreach (var role in roles)
                  {
                      _roleManager.CreateAsync(role).Wait();
                  }
  
                  foreach (var user in users)
                  {
                      _userManager.CreateAsync(user, "password").Wait();
                      _userManager.AddToRoleAsync(user, "Student").Wait();
                  }
  
                  var adminUser = new User
                  {
                      UserName = "Admin",
                      Email = "admin.social@gmail.com",
                      Created = System.DateTime.Now
                  };
  
                  IdentityResult result = _userManager.CreateAsync(adminUser, "password").Result;
                  if (result.Succeeded)
                  {
                      var admin = _userManager.FindByNameAsync("Admin").Result; ;
                      _userManager.AddToRoleAsync(admin, "Admin").Wait();
                  }
  
                  var superAdminUser = new User
                  {
                      UserName = "SuperAdmin",
                      Email = "sadmin.social@gmail.com",
                      Created = System.DateTime.Now
                  };
  
                  IdentityResult result2 = _userManager.CreateAsync(superAdminUser, "password").Result;
                  if (result2.Succeeded)
                  {
                      var superAdmin = _userManager.FindByNameAsync("SuperAdmin").Result;
                      _userManager.AddToRolesAsync(superAdmin, new[] { "Admin", "SuperAdmin" }).Wait();
                  }
              }
  
  
  
  
          }
  
  
      }
  </code></pre>
  
  <p>Here is appsettings.json file code</p>
  
  <pre><code>{
    "AppSettings": {
      "Token": "super secret key"
    },
    "ConnectionStrings": {
      "DefaultConnection": "Server=localhost; Database=socialApp; Uid=root; Pwd=mysql12$#;",
      "DefaultConnection2": "Data Source=DatingApp.db"
    },
    "Logging": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "AllowedHosts": "*"
  }
  </code></pre>
  
  <p>please help me to solve this issue.
  thanks &amp; regards</p>