// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext <ApplicationDbContext>(options => options.UseNpgsql(ConnectionBuilder.GetConnectionString())); services.AddRazorPages(); }
public InitAppData() { IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>(); optionsBuilder.UseNpgsql(ConnectionBuilder.GetConnectionString()); _context = new ApplicationDbContext(optionsBuilder.Options); _context.Database.EnsureCreated(); }
public void TestMethod1() { CurrentMappings currentMappings; Application app; // Here the CORE_USER entity is NOT being ignored currentMappings = new CurrentMappings((modelBuilder) => { modelBuilder.Configurations.Add(new CORE_SESSIONConfiguration()); modelBuilder.Configurations.Add(new CORE_USERConfiguration()); modelBuilder.Filter("test", (CORE_USER b, bool isDeleted) => true, () => false); }); GlobalDBConfiguration config = new GlobalDBConfiguration(); DbConfiguration.SetConfiguration(config); app = new Application(currentMappings); app.ResetDatabase(); app.DoMerge(); // Here we ignore both the entity and the field that has the FK currentMappings = new CurrentMappings((modelBuilder) => { modelBuilder.Configurations.Add(new CORE_SESSIONConfiguration()); modelBuilder.Entity <CORE_SESSION>().Ignore(t => t.fk_core_user); modelBuilder.Ignore <CORE_USER>(); }); ZzzUtils.ClearZzzAndEfCaches(ConnectionBuilder.GetConnectionString()); var dcs = new DBModelSession(); app = new Application(currentMappings); app.DoMerge(); }