ConnectionLogDBContext.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. namespace EVCB_OCPP.Domain
  2. {
  3. using EVCB_OCPP.Domain.Models.Database;
  4. using Microsoft.EntityFrameworkCore;
  5. using System;
  6. using System.Linq;
  7. public class ConnectionLogDBContext : DbContext
  8. {
  9. // 您的內容已設定為使用應用程式組態檔 (App.config 或 Web.config)
  10. // 中的 'ConnectionLogDBContext' 連接字串。根據預設,這個連接字串的目標是
  11. // 您的 LocalDb 執行個體上的 'EVCB_OCPP.Domain.ConnectionLogDBContext' 資料庫。
  12. //
  13. // 如果您的目標是其他資料庫和 (或) 提供者,請修改
  14. // 應用程式組態檔中的 'ConnectionLogDBContext' 連接字串。
  15. public ConnectionLogDBContext(): base()
  16. {
  17. //Database.SetInitializer<ConnectionLogDBContext>(null);
  18. //this.Configuration.AutoDetectChangesEnabled = false;
  19. //this.Configuration.ValidateOnSaveEnabled = false;
  20. //this.Configuration.AutoDetectChangesEnabled = false;
  21. //this.Configuration.LazyLoadingEnabled = false;
  22. //this.Database.CommandTimeout = 180;
  23. }
  24. public ConnectionLogDBContext(DbContextOptions<ConnectionLogDBContext> options) : base(options)
  25. {
  26. }
  27. // 針對您要包含在模型中的每種實體類型新增 DbSet。如需有關設定和使用
  28. // Code First 模型的詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkId=390109。
  29. public virtual DbSet<MachineConnectionLog> MachineConnectionLog { get; set; }
  30. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  31. {
  32. //optionsBuilder.UseSqlServer("data source=172.1.2.187;initial catalog=StandardOCPP_ConnectionLog;persist security info=True;user id=sa;password=Ph0930118811;MultipleActiveResultSets=True;App=EntityFramework");
  33. base.OnConfiguring(optionsBuilder);
  34. }
  35. }
  36. //public class MyEntity
  37. //{
  38. // public int Id { get; set; }
  39. // public string Name { get; set; }
  40. //}
  41. }