TestDbContext.cs 896 B

123456789101112131415161718192021222324252627
  1. using System.Diagnostics;
  2. using Microsoft.EntityFrameworkCore;
  3. using Quadarax.Foundation.Core.Data.Domain;
  4. namespace qdr.fnd.core.test.Repositories.Fakes
  5. {
  6. public class TestDbContext : DataDomain, IDataDomain
  7. {
  8. public DbSet<TestDao> Daos { get; set; } = null!;
  9. public TestDbContext() : base(new DbContextOptions<TestDbContext>())
  10. {
  11. }
  12. public TestDbContext(DbContextOptions options) : base(options)
  13. {
  14. }
  15. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  16. {
  17. var dbName = "test" + DateTime.Now.ToFileTime().ToString();
  18. optionsBuilder.UseInMemoryDatabase(dbName)
  19. .LogTo(message => Debug.WriteLine("EFSQL>>" + message));
  20. Debug.WriteLine($"*** {GetType().Name} - Context created [{dbName}]");
  21. }
  22. }
  23. }