Explorar o código

Identity database connection fix

ganahrhr %!s(int64=2) %!d(string=hai) anos
pai
achega
e070bdca4f
Modificáronse 2 ficheiros con 11 adicións e 4 borrados
  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",