MainDBContext.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. using System;
  2. using System.Collections.Generic;
  3. using EVCB_OCPP.Domain.Models.MainDb;
  4. using Microsoft.EntityFrameworkCore;
  5. namespace EVCB_OCPP.Domain;
  6. public partial class MainDBContext : DbContext
  7. {
  8. public MainDBContext()
  9. {
  10. }
  11. public MainDBContext(DbContextOptions<MainDBContext> options)
  12. : base(options)
  13. {
  14. }
  15. public virtual DbSet<ConnectorMeterValueRecord> ConnectorMeterValueRecords { get; set; }
  16. public virtual DbSet<ConnectorStatus> ConnectorStatuses { get; set; }
  17. public virtual DbSet<Customer> Customers { get; set; }
  18. public virtual DbSet<LoadingBalance> LoadingBalances { get; set; }
  19. public virtual DbSet<Machine> Machines { get; set; }
  20. public virtual DbSet<MachineConfiguration> MachineConfigurations { get; set; }
  21. public virtual DbSet<MachineError> MachineErrors { get; set; }
  22. public virtual DbSet<MachineOperateRecord> MachineOperateRecords { get; set; }
  23. public virtual DbSet<MachineVersionFile> MachineVersionFiles { get; set; }
  24. public virtual DbSet<MigrationHistory> MigrationHistories { get; set; }
  25. public virtual DbSet<Ocmf> Ocmfs { get; set; }
  26. public virtual DbSet<ServerMessage> ServerMessages { get; set; }
  27. public virtual DbSet<TransactionRecord> TransactionRecords { get; set; }
  28. public virtual DbSet<UploadFile> UploadFiles { get; set; }
  29. public virtual DbSet<VConnectorStatus> VConnectorStatuses { get; set; }
  30. public virtual DbSet<VConnectorStatusCombind> VConnectorStatusCombinds { get; set; }
  31. public virtual DbSet<VMachine> VMachines { get; set; }
  32. public virtual DbSet<VMachineCombind> VMachineCombinds { get; set; }
  33. protected override void OnModelCreating(ModelBuilder modelBuilder)
  34. {
  35. modelBuilder.UseCollation("Chinese_Taiwan_Stroke_CI_AS");
  36. modelBuilder.Entity<ConnectorMeterValueRecord>(entity =>
  37. {
  38. entity.HasKey(e => e.Id).HasName("PK_dbo.ConnectorMeterValueRecord");
  39. entity.ToTable("ConnectorMeterValueRecord");
  40. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  41. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  42. entity.Property(e => e.Value).HasMaxLength(10);
  43. });
  44. modelBuilder.Entity<ConnectorStatus>(entity =>
  45. {
  46. entity.HasKey(e => e.Id).HasName("PK_dbo.ConnectorStatus");
  47. entity.ToTable("ConnectorStatus");
  48. entity.Property(e => e.Id).HasMaxLength(36);
  49. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  50. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  51. entity.Property(e => e.ErrorInfo).HasMaxLength(50);
  52. entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)");
  53. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  54. entity.Property(e => e.VendorId).HasMaxLength(255);
  55. });
  56. modelBuilder.Entity<Customer>(entity =>
  57. {
  58. entity.HasKey(e => e.Id).HasName("PK_dbo.Customer");
  59. entity.ToTable("Customer");
  60. entity.Property(e => e.Id).ValueGeneratedNever();
  61. entity.Property(e => e.ApiCustomerId).HasMaxLength(36);
  62. entity.Property(e => e.ApiKey).HasMaxLength(128);
  63. entity.Property(e => e.ApiKeyUpdatedOn).HasColumnType("datetime");
  64. entity.Property(e => e.ApiUrl).HasMaxLength(256);
  65. entity.Property(e => e.CreatedBy).HasMaxLength(50);
  66. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  67. entity.Property(e => e.Deadline).HasColumnType("datetime");
  68. entity.Property(e => e.EnableTtia).HasColumnName("EnableTTIA");
  69. entity.Property(e => e.Ftphost)
  70. .HasMaxLength(50)
  71. .HasColumnName("FTPHost");
  72. entity.Property(e => e.Ftppassword)
  73. .HasMaxLength(20)
  74. .HasColumnName("FTPPassword");
  75. entity.Property(e => e.Ftppath).HasColumnName("FTPPath");
  76. entity.Property(e => e.Ftpuser)
  77. .HasMaxLength(20)
  78. .HasColumnName("FTPUser");
  79. entity.Property(e => e.Name).HasMaxLength(50);
  80. entity.Property(e => e.PartnerId).HasMaxLength(36);
  81. entity.Property(e => e.TtiaApikey)
  82. .HasMaxLength(12)
  83. .HasColumnName("TTIA_APIKey");
  84. entity.Property(e => e.TtiaApiurl)
  85. .HasMaxLength(110)
  86. .HasColumnName("TTIA_APIUrl");
  87. entity.Property(e => e.TtiaCustomerId).HasColumnName("TTIA_CustomerId");
  88. entity.Property(e => e.TtiaEquipmentProvider)
  89. .HasMaxLength(10)
  90. .HasColumnName("TTIA_EquipmentProvider");
  91. entity.Property(e => e.UpdatedBy).HasMaxLength(50);
  92. entity.Property(e => e.UpdatedOn).HasColumnType("datetime");
  93. });
  94. modelBuilder.Entity<LoadingBalance>(entity =>
  95. {
  96. entity.ToTable("LoadingBalance");
  97. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  98. entity.Property(e => e.FinishedOn).HasColumnType("datetime");
  99. entity.Property(e => e.MachineId)
  100. .IsRequired()
  101. .HasMaxLength(36);
  102. entity.Property(e => e.Power).HasColumnType("decimal(10, 2)");
  103. });
  104. modelBuilder.Entity<Machine>(entity =>
  105. {
  106. entity.HasKey(e => e.Id).HasName("PK_dbo.Machine");
  107. entity.ToTable("Machine");
  108. entity.Property(e => e.Id).HasMaxLength(36);
  109. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  110. entity.Property(e => e.ChargeBoxSerialNumber).HasMaxLength(25);
  111. entity.Property(e => e.ChargePointModel).HasMaxLength(20);
  112. entity.Property(e => e.ChargePointSerialNumber).HasMaxLength(25);
  113. entity.Property(e => e.ChargePointVendor).HasMaxLength(20);
  114. entity.Property(e => e.Comment).HasMaxLength(100);
  115. entity.Property(e => e.ConnectorPowerType).HasMaxLength(50);
  116. entity.Property(e => e.ConnectorType).HasMaxLength(50);
  117. entity.Property(e => e.CreatedBy).HasMaxLength(50);
  118. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  119. entity.Property(e => e.FwAssignedVersion).HasColumnName("FW_AssignedVersion");
  120. entity.Property(e => e.FwCurrentVersion)
  121. .HasMaxLength(50)
  122. .HasColumnName("FW_CurrentVersion");
  123. entity.Property(e => e.FwVersionReport).HasColumnName("FW_VersionReport");
  124. entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime");
  125. entity.Property(e => e.Iccid).HasMaxLength(20);
  126. entity.Property(e => e.Imsi).HasMaxLength(20);
  127. entity.Property(e => e.Latitude).HasColumnType("decimal(10, 6)");
  128. entity.Property(e => e.Longitude).HasColumnType("decimal(10, 6)");
  129. entity.Property(e => e.MeterSerialNumber).HasMaxLength(25);
  130. entity.Property(e => e.MeterType).HasMaxLength(25);
  131. entity.Property(e => e.ModelName)
  132. .IsRequired()
  133. .HasMaxLength(50)
  134. .HasDefaultValueSql("('')");
  135. entity.Property(e => e.OfflineOn).HasColumnType("datetime");
  136. entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)");
  137. entity.Property(e => e.Ttiatag).HasColumnName("TTIATag");
  138. entity.Property(e => e.VendorId)
  139. .HasMaxLength(50)
  140. .HasDefaultValueSql("('Zerova')");
  141. entity.HasOne(d => d.Customer).WithMany(p => p.Machines)
  142. .HasForeignKey(d => d.CustomerId)
  143. .HasConstraintName("FK_dbo.Machine_dbo.Customer_CustomerId");
  144. });
  145. modelBuilder.Entity<MachineConfiguration>(entity =>
  146. {
  147. entity.HasKey(e => e.Id).HasName("PK_dbo.MachineConfigurations");
  148. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  149. entity.Property(e => e.ConfigureName).HasMaxLength(50);
  150. entity.Property(e => e.ConfigureSetting).HasMaxLength(500);
  151. });
  152. modelBuilder.Entity<MachineError>(entity =>
  153. {
  154. entity.HasKey(e => e.Id).HasName("PK_dbo.MachineError");
  155. entity.ToTable("MachineError");
  156. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  157. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  158. entity.Property(e => e.ErrorInfo).HasMaxLength(50);
  159. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  160. entity.Property(e => e.VendorId).HasMaxLength(255);
  161. });
  162. modelBuilder.Entity<MachineOperateRecord>(entity =>
  163. {
  164. entity.HasKey(e => e.Id).HasName("PK_dbo.MachineOperateRecord");
  165. entity.ToTable("MachineOperateRecord");
  166. entity.Property(e => e.Action).HasMaxLength(30);
  167. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  168. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  169. entity.Property(e => e.EvseStatus).HasColumnName("EVSE_Status");
  170. entity.Property(e => e.EvseValue).HasColumnName("EVSE_Value");
  171. entity.Property(e => e.FinishedOn).HasColumnType("datetime");
  172. entity.Property(e => e.ReportedOn).HasColumnType("datetime");
  173. entity.Property(e => e.SerialNo).HasMaxLength(36);
  174. });
  175. modelBuilder.Entity<MachineVersionFile>(entity =>
  176. {
  177. entity.HasKey(e => e.Id).HasName("PK_dbo.MachineVersionFile");
  178. entity.ToTable("MachineVersionFile");
  179. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  180. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  181. entity.Property(e => e.UploadFileId)
  182. .IsRequired()
  183. .HasMaxLength(36);
  184. entity.HasOne(d => d.UploadFile).WithMany(p => p.MachineVersionFiles)
  185. .HasForeignKey(d => d.UploadFileId)
  186. .HasConstraintName("FK_dbo.MachineVersionFile_dbo.UploadFile_UploadFileId");
  187. });
  188. modelBuilder.Entity<MigrationHistory>(entity =>
  189. {
  190. entity.HasKey(e => new { e.MigrationId, e.ContextKey }).HasName("PK_dbo.__MigrationHistory");
  191. entity.ToTable("__MigrationHistory");
  192. entity.Property(e => e.MigrationId).HasMaxLength(150);
  193. entity.Property(e => e.ContextKey).HasMaxLength(300);
  194. entity.Property(e => e.Model).IsRequired();
  195. entity.Property(e => e.ProductVersion)
  196. .IsRequired()
  197. .HasMaxLength(32);
  198. });
  199. modelBuilder.Entity<Ocmf>(entity =>
  200. {
  201. entity.HasKey(e => e.Id).HasName("PK_dbo.OCMF");
  202. entity.ToTable("OCMF");
  203. entity.Property(e => e.DataString).HasMaxLength(2048);
  204. entity.Property(e => e.PublicKey).HasMaxLength(256);
  205. });
  206. modelBuilder.Entity<ServerMessage>(entity =>
  207. {
  208. entity.HasKey(e => e.Id).HasName("PK_dbo.ServerMessage");
  209. entity.ToTable("ServerMessage");
  210. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  211. entity.Property(e => e.CreatedBy).HasMaxLength(36);
  212. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  213. entity.Property(e => e.OutAction).HasMaxLength(30);
  214. entity.Property(e => e.ReceivedOn).HasColumnType("datetime");
  215. entity.Property(e => e.SerialNo).HasMaxLength(36);
  216. entity.Property(e => e.UpdatedOn).HasColumnType("datetime");
  217. });
  218. modelBuilder.Entity<TransactionRecord>(entity =>
  219. {
  220. entity.HasKey(e => e.Id).HasName("PK_dbo.TransactionRecord");
  221. entity.ToTable("TransactionRecord");
  222. entity.Property(e => e.ChargeBoxId)
  223. .IsRequired()
  224. .HasMaxLength(50);
  225. entity.Property(e => e.Cost).HasColumnType("decimal(18, 2)");
  226. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  227. entity.Property(e => e.Fee).HasMaxLength(1500);
  228. entity.Property(e => e.MeterStart).HasColumnType("decimal(18, 2)");
  229. entity.Property(e => e.MeterStop).HasColumnType("decimal(18, 2)");
  230. entity.Property(e => e.Receipt).HasMaxLength(3000);
  231. entity.Property(e => e.StartIdTag).HasMaxLength(20);
  232. entity.Property(e => e.StartSoc)
  233. .HasMaxLength(3)
  234. .HasColumnName("StartSOC");
  235. entity.Property(e => e.StartTime).HasColumnType("datetime");
  236. entity.Property(e => e.StartTransactionReportedOn).HasColumnType("datetime");
  237. entity.Property(e => e.StopIdTag).HasMaxLength(20);
  238. entity.Property(e => e.StopReason).HasMaxLength(60);
  239. entity.Property(e => e.StopSoc)
  240. .HasMaxLength(3)
  241. .HasColumnName("StopSOC");
  242. entity.Property(e => e.StopTime).HasColumnType("datetime");
  243. entity.Property(e => e.StopTransactionReportedOn).HasColumnType("datetime");
  244. entity.Property(e => e.UpdatedOn).HasColumnType("datetime");
  245. entity.Property(e => e.UploadedtoTtia).HasColumnName("UploadedtoTTIA");
  246. });
  247. modelBuilder.Entity<UploadFile>(entity =>
  248. {
  249. entity.HasKey(e => e.Id).HasName("PK_dbo.UploadFile");
  250. entity.ToTable("UploadFile");
  251. entity.Property(e => e.Id).HasMaxLength(36);
  252. entity.Property(e => e.CreatedBy).HasMaxLength(50);
  253. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  254. entity.Property(e => e.FileExtensionName).HasMaxLength(50);
  255. entity.Property(e => e.FileMd5)
  256. .HasMaxLength(50)
  257. .HasColumnName("FileMD5");
  258. entity.Property(e => e.FileName)
  259. .IsRequired()
  260. .HasMaxLength(500);
  261. entity.Property(e => e.FilePath)
  262. .IsRequired()
  263. .HasMaxLength(500);
  264. entity.Property(e => e.FileType).HasMaxLength(200);
  265. entity.Property(e => e.FileUrl).HasMaxLength(512);
  266. entity.Property(e => e.ModelName)
  267. .IsRequired()
  268. .HasMaxLength(50);
  269. entity.Property(e => e.OriginName)
  270. .IsRequired()
  271. .HasMaxLength(500);
  272. entity.Property(e => e.VendorId)
  273. .IsRequired()
  274. .HasMaxLength(50);
  275. });
  276. modelBuilder.Entity<VConnectorStatus>(entity =>
  277. {
  278. entity
  279. .HasNoKey()
  280. .ToView("vConnectorStatus");
  281. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  282. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  283. entity.Property(e => e.ErrorInfo).HasMaxLength(50);
  284. entity.Property(e => e.Id)
  285. .IsRequired()
  286. .HasMaxLength(36);
  287. entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)");
  288. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  289. entity.Property(e => e.VendorId).HasMaxLength(255);
  290. });
  291. modelBuilder.Entity<VConnectorStatusCombind>(entity =>
  292. {
  293. entity
  294. .HasNoKey()
  295. .ToView("vConnectorStatusCombind");
  296. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  297. entity.Property(e => e.Ocpp)
  298. .IsRequired()
  299. .HasMaxLength(3)
  300. .IsUnicode(false)
  301. .HasColumnName("OCPP");
  302. entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)");
  303. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  304. });
  305. modelBuilder.Entity<VMachine>(entity =>
  306. {
  307. entity
  308. .HasNoKey()
  309. .ToView("vMachine");
  310. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  311. entity.Property(e => e.ConnectorType).HasMaxLength(50);
  312. entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime");
  313. entity.Property(e => e.Id)
  314. .IsRequired()
  315. .HasMaxLength(36);
  316. entity.Property(e => e.ModelName)
  317. .IsRequired()
  318. .HasMaxLength(50);
  319. entity.Property(e => e.OfflineOn).HasColumnType("datetime");
  320. entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)");
  321. entity.Property(e => e.Ttiatag).HasColumnName("TTIATag");
  322. entity.Property(e => e.VendorId).HasMaxLength(50);
  323. });
  324. modelBuilder.Entity<VMachineCombind>(entity =>
  325. {
  326. entity
  327. .HasNoKey()
  328. .ToView("vMachineCombind");
  329. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  330. entity.Property(e => e.ConnectorType).HasMaxLength(50);
  331. entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime");
  332. entity.Property(e => e.Id)
  333. .IsRequired()
  334. .HasMaxLength(36);
  335. entity.Property(e => e.ModelName)
  336. .IsRequired()
  337. .HasMaxLength(50);
  338. entity.Property(e => e.Ocpp)
  339. .IsRequired()
  340. .HasMaxLength(3)
  341. .IsUnicode(false)
  342. .HasColumnName("OCPP");
  343. entity.Property(e => e.OfflineOn).HasColumnType("datetime");
  344. entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)");
  345. entity.Property(e => e.Ttiatag).HasColumnName("TTIATag");
  346. entity.Property(e => e.VendorId).HasMaxLength(50);
  347. });
  348. OnModelCreatingPartial(modelBuilder);
  349. }
  350. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  351. }