Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- modelBuilder.Ignore<Author>();
- }
- if (!isRuntime)
- {
- modelBuilder.Ignore<Author>();
- }
- public void ConfigureServices(IServiceCollection services)
- {
- //other things that are irrelevant
- var connectionString = Startup.Configuration["connectionStrings:conStrExpress"];
- services.AddScoped<IResearchCreationsRepository, ResearchCreationsRepository>();
- services.AddDbContext<ResearchCreationsContext>(o => o.UseSqlServer(connectionString));
- }
- public class ResearchCreationsContext: DbContext
- {
- public bool isRuntime { get; set; } = false;
- public DbSet<Research> Research { get; set; }
- public DbSet<SearchedCreations> SearchedCreations { get; set; }
- public ResearchCreationsContext(DbContextOptions<ResearchCreationsContext> options)
- : base(options)
- {
- Database.Migrate();
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- if (!isRuntime)
- {
- modelBuilder.Ignore<SearchedCreations>();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement