// Zapisuje connection string aby nie było potrzebne precyzowanie go podczas operacji na danych.
        public static void SetConnectionString(MsSqlConnectionString connectionString)
        {
            var config = OpenExeConfiguration(ConfigurationUserLevel.None);
            var connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings");

            connectionStringsSection.ConnectionStrings["AppDatabase"].ConnectionString = connectionString.Value;
            config.Save();
            Logger.Log($"{connectionString.Value} is now setup as default connection string.");
        }
예제 #2
0
 public MsSqlDbContextProvider(MsSqlConnectionString msSqlConnectionString)
 {
     _options = new DbContextOptionsBuilder <TestDbContext>()
                .UseSqlServer(msSqlConnectionString.Value)
                .Options;
 }