/// <summary> /// 定义种子数据初始化过程 /// </summary> /// <param name="context">数据上下文</param> public void Action(UbpDbContext context) { //if (context.Set<Role>().Count(p => p.Name == "系统管理员") == 0) // context.Set<Role>().AddOrUpdate(new Role() { Name = "系统管理员", Remark = "系统管理员角色,拥有系统最高权限", IsAdmin = true, IsSystem = true, CreatedTime = DateTime.Now }); //if (context.Set<User>().Count(p => p.UserName == "admin") == 0) // context.Set<User>().AddOrUpdate(new User() // { // UserName = "******", // NickName = "系统管理员", // Email = "*****@*****.**", // EmailConfirmed = false, // PasswordHash = "AFJuxDmNkeA5Rg+djBwaDDhJFCEPC5fts9HtkV2zsu5q9L9OfPQ3sLmbIKJpGNlPCQ==", // PhoneNumberConfirmed = false, // TwoFactorEnabled = false, // LockoutEnabled = true // }); //Host seed //new InitialHostDbBuilder(context).Create(); //Default tenant seed (in host database). //new DefaultTenantCreator(context).Create(); //new TenantRoleAndUserBuilder(context, 1).Create(); }
static void Main(string[] args) { Devart.Data.Oracle.OracleMonitor monitor = new Devart.Data.Oracle.OracleMonitor() { IsActive = true }; Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig devartConfig = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance; devartConfig.Workarounds.IgnoreSchemaName = true; devartConfig.Workarounds.DisableQuoting = true; devartConfig.CodeFirstOptions.UseDateTimeAsDate = true; devartConfig.CodeFirstOptions.UseNonLobStrings = true; devartConfig.CodeFirstOptions.UseNonUnicodeStrings = true; devartConfig.CodeFirstOptions.TruncateLongDefaultNames = true; using (var bootstrapper = AbpBootstrapper.Create <TestConsoleAppModule>()) { bootstrapper.IocManager .IocContainer .AddFacility <LoggingFacility>(f => f.UseLog4Net().WithConfig("log4net.config")); bootstrapper.Initialize(); //Getting a Tester object from DI and running it using (var tester = bootstrapper.IocManager.ResolveAsDisposable <Tester>()) { tester.Object.TestEntitiyMapToDto(); } //Disposes tester and all it's dependencies Console.WriteLine("Press enter to exit..."); Console.ReadLine(); } #region 手工创建DbContext ////UbpConfig config = UbpConfig.Instance; ////IDatabaseInitializer databaseInitializer = new DatabaseInitializer(); ////databaseInitializer.Initialize(config.DbContextInitializerConfig); //Database.SetInitializer<UbpDbContext>(null); ////Database.SetInitializer(new OracleDevartCreateDatabaseIfNotExistsWithSeed()); ////Database.SetInitializer(new MigrateDatabaseToLatestVersion<UbpDbContext, OracleDevartMigrationsConfiguration>()); UbpDbContext dbContext = new UbpDbContext("default"); ////if (!dbContext.Database.Exists()) ////{ //// Database.SetInitializer(new OracleDevartCreateDatabaseIfNotExistsWithSeed()); ////} ////else ////{ //// Database.SetInitializer(new MigrateDatabaseToLatestVersion<UbpDbContext, OracleDevartMigrationsConfiguration>()); ////} Add(dbContext); //dbContext.DisableFilter(AbpDataFilters.SoftDelete); //Query(dbContext); //Console.WriteLine("Press enter to exit..."); //Console.ReadLine(); #endregion }
private static void Query(UbpDbContext context) { //var datas = context.Modules; //Console.WriteLine("数据有:"); //foreach (var data in datas) //{ // Console.WriteLine("{0}", data.FullName); //} }
private static void Add(UbpDbContext context) { //var m = context.Modules.Add(new TG.UBP.Domain.Entity.Module() { EnCode = "test21", FullName = "test21" }); //context.Modules.Add(new TG.UBP.Domain.Entity.Module() { EnCode = "test2", FullName = "test2" }); //context.Modules.Add(new TG.UBP.Domain.Entity.Module() { EnCode = "test3", FullName = "test3" }); //context.Users.Add(new TG.UBP.Domain.Entity.User() { EnCode = "test1", FullName = "test1" }); //context.Users.Add(new TG.UBP.Domain.Entity.User() { EnCode = "test2", FullName = "test2" }); //context.SaveChanges(); }
/// <summary> /// 定义种子数据初始化过程 /// </summary> /// <param name="context">数据上下文</param> public void Action(UbpDbContext context) { context.DisableAllFilters(); context.EntityChangeEventHelper = NullEntityChangeEventHelper.Instance; context.EventBus = NullEventBus.Instance; if (Tenant == null) { //Host seed new InitialHostDbBuilder(context).Create(); //Default tenant seed (in host database). new DefaultTenantBuilder(context).Create(); new TenantRoleAndUserBuilder(context, 1).Create(); } else { //You can add seed for tenant databases using Tenant property... } context.SaveChanges(); }
public HostRoleAndUserCreator(UbpDbContext context) { _context = context; }
public InitialHostDbBuilder(UbpDbContext context) { _context = context; }
public DefaultSettingsCreator(UbpDbContext context) { _context = context; }
public DefaultTenantBuilder(UbpDbContext context) { _context = context; }
public DefaultEditionCreator(UbpDbContext context) { _context = context; }
public TenantRoleAndUserBuilder(UbpDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public DefaultLanguagesCreator(UbpDbContext context) { _context = context; }