EasyDbContext.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Data.Common;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.EntityFrameworkCore.Storage;
  6. namespace EasyDevCore.Database
  7. {
  8. /// <summary>
  9. ///
  10. /// </summary>
  11. /// <seealso cref="Microsoft.EntityFrameworkCore.DbContext" />
  12. public class EasyDbContext: DbContext
  13. {
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="EasyDbContext"/> class.
  16. /// </summary>
  17. /// <param name="options">The options for this context.</param>
  18. public EasyDbContext(DbContextOptions options) : base(options)
  19. {
  20. }
  21. /// <summary>
  22. /// Initializes a new instance of the <see cref="EasyDbContext"/> class.
  23. /// </summary>
  24. protected EasyDbContext()
  25. {
  26. }
  27. /// <summary>
  28. /// <para>
  29. /// Override this method to configure the database (and other options) to be used for this context.
  30. /// This method is called for each instance of the context that is created.
  31. /// The base implementation does nothing.
  32. /// </para>
  33. /// <para>
  34. /// In situations where an instance of <see cref="T:Microsoft.EntityFrameworkCore.DbContextOptions" /> may or may not have been passed
  35. /// to the constructor, you can use <see cref="P:Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.IsConfigured" /> to determine if
  36. /// the options have already been set, and skip some or all of the logic in
  37. /// <see cref="M:Microsoft.EntityFrameworkCore.DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)" />.
  38. /// </para>
  39. /// </summary>
  40. /// <param name="optionsBuilder">A builder used to create or modify options for this context. Databases (and other extensions)
  41. /// typically define extension methods on this object that allow you to configure the context.</param>
  42. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.AddInterceptors(new EasyCommandInterceptor());
  43. }
  44. }