Parcourir la source

Identity database connection fix

ganahrhr il y a 2 ans
Parent
commit
e070bdca4f
2 fichiers modifiés avec 11 ajouts et 4 suppressions
  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
         public void ConfigureServices(IServiceCollection services)
         {
+            string connection;
+#if DEBUG
+            connection = "DevConnection";
+#else
+            connection = "ProdConnection";
+#endif
             services.AddDbContext<ApplicationDbContext>(options =>
                 options.UseMySQL(
-                Configuration.GetConnectionString("DefaultConnection")));
+                Configuration.GetConnectionString(connection)));
             services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
                 .AddRoles<IdentityRole>()
                 .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": {
         "LogLevel": {
             "Default": "Information",