Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. {
  2. modelBuilder.Ignore<Author>();
  3. }
  4.  
  5. if (!isRuntime)
  6. {
  7. modelBuilder.Ignore<Author>();
  8. }
  9.  
  10. public void ConfigureServices(IServiceCollection services)
  11. {
  12. //other things that are irrelevant
  13. var connectionString = Startup.Configuration["connectionStrings:conStrExpress"];
  14. services.AddScoped<IResearchCreationsRepository, ResearchCreationsRepository>();
  15. services.AddDbContext<ResearchCreationsContext>(o => o.UseSqlServer(connectionString));
  16. }
  17.  
  18. public class ResearchCreationsContext: DbContext
  19. {
  20. public bool isRuntime { get; set; } = false;
  21. public DbSet<Research> Research { get; set; }
  22. public DbSet<SearchedCreations> SearchedCreations { get; set; }
  23.  
  24. public ResearchCreationsContext(DbContextOptions<ResearchCreationsContext> options)
  25. : base(options)
  26. {
  27. Database.Migrate();
  28. }
  29.  
  30. protected override void OnModelCreating(ModelBuilder modelBuilder)
  31. {
  32. if (!isRuntime)
  33. {
  34. modelBuilder.Ignore<SearchedCreations>();
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement