コード例 #1
0
        public PluginPermissionsManager GetPermissionsManager(string connectionString)
        {
            var contextFactory = new InventoryPnContextFactory();
            var context        = contextFactory.CreateDbContext(new[] { connectionString });

            return(new PluginPermissionsManager(context));
        }
コード例 #2
0
        private void GetContext(string connectionStr)
        {
            var contextFactory = new InventoryPnContextFactory();

            DbContext = contextFactory.CreateDbContext(new[] { connectionStr });

            DbContext.Database.Migrate();
            DbContext.Database.EnsureCreated();
        }
コード例 #3
0
        public void SeedDatabase(string connectionString)
        {
            // Get DbContext
            var contextFactory = new InventoryPnContextFactory();

            using var context = contextFactory.CreateDbContext(new[] { connectionString });

            // Seed configuration
            InventoryPluginSeed.SeedData(context);
        }
コード例 #4
0
        public void ConfigureDbContext(IServiceCollection services, string connectionString)
        {
            _connectionString = connectionString;
            services.AddDbContext <InventoryPnDbContext>(o => o.UseMySql(connectionString, new MariaDbServerVersion(
                                                                             new Version(10, 4, 0)), mySqlOptionsAction: builder =>
            {
                builder.EnableRetryOnFailure();
                builder.MigrationsAssembly(PluginAssembly().FullName);
            }));

            var contextFactory = new InventoryPnContextFactory();
            var context        = contextFactory.CreateDbContext(new[] { connectionString });

            context.Database.Migrate();

            // Seed database
            SeedDatabase(connectionString);
        }
コード例 #5
0
        private InventoryPnDbContext GetContext()
        {
            var contextFactory = new InventoryPnContextFactory();

            return(contextFactory.CreateDbContext(new[] { _connectionString }));
        }