Browse Source

Identity database connection fix

ganahrhr 2 years ago
parent
commit
e070bdca4f
2 changed files with 11 additions and 4 deletions
  1. 7 1
      Startup.cs
  2. 4 3
      appsettings.json

+ 7 - 1
Startup.cs

@@ -45,9 +45,15 @@ namespace HyperCube
         // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
         // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
         public void ConfigureServices(IServiceCollection services)
         public void ConfigureServices(IServiceCollection services)
         {
         {
+            string connection;
+#if DEBUG
+            connection = "DevConnection";
+#else
+            connection = "ProdConnection";
+#endif
             services.AddDbContext<ApplicationDbContext>(options =>
             services.AddDbContext<ApplicationDbContext>(options =>
                 options.UseMySQL(
                 options.UseMySQL(
-                Configuration.GetConnectionString("DefaultConnection")));
+                Configuration.GetConnectionString(connection)));
             services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
             services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
                 .AddRoles<IdentityRole>()
                 .AddRoles<IdentityRole>()
                 .AddEntityFrameworkStores<ApplicationDbContext>();
                 .AddEntityFrameworkStores<ApplicationDbContext>();

+ 4 - 3
appsettings.json

@@ -1,7 +1,8 @@
 {
 {
-    "ConnectionStrings": {
-        "DefaultConnection": "server=dmatter.net;port=3306;database=documents;uid=promsystem;password=PrmSystem212"
-    },
+  "ConnectionStrings": {
+    "DevConnection": "server=dmatter.net;port=3306;database=documents_dev;uid=promsystem;password=PrmSystem212",
+    "ProdConnection": "server=dmatter.net;port=3306;database=documents;uid=promsystem;password=PrmSystem212"
+  },
     "Logging": {
     "Logging": {
         "LogLevel": {
         "LogLevel": {
             "Default": "Information",
             "Default": "Information",