MainDBContext.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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 OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  34. //#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
  35. // => optionsBuilder.UseSqlServer("data source=zerova-ev-dev.database.windows.net;initial catalog=StandardOCPP_Main;persist security info=True;user id=azdevsoftware;password=1h52dev#az;MultipleActiveResultSets=True;App=EntityFramework");
  36. protected override void OnModelCreating(ModelBuilder modelBuilder)
  37. {
  38. modelBuilder.UseCollation("Chinese_Taiwan_Stroke_CI_AS");
  39. modelBuilder.Entity<ConnectorMeterValueRecord>(entity =>
  40. {
  41. entity.HasKey(e => e.Id).HasName("PK_dbo.ConnectorMeterValueRecord");
  42. entity.ToTable("ConnectorMeterValueRecord");
  43. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  44. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  45. entity.Property(e => e.Value).HasMaxLength(10);
  46. });
  47. modelBuilder.Entity<ConnectorStatus>(entity =>
  48. {
  49. entity.HasKey(e => e.Id).HasName("PK_dbo.ConnectorStatus");
  50. entity.ToTable("ConnectorStatus");
  51. entity.HasIndex(e => new { e.ChargeBoxId, e.ConnectorId }, "IX_ConnectorStatus").IsUnique();
  52. entity.Property(e => e.Id).HasMaxLength(36);
  53. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  54. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  55. entity.Property(e => e.ErrorInfo).HasMaxLength(50);
  56. entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)");
  57. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  58. entity.Property(e => e.VendorId).HasMaxLength(255);
  59. });
  60. modelBuilder.Entity<Customer>(entity =>
  61. {
  62. entity.HasKey(e => e.Id).HasName("PK_dbo.Customer");
  63. entity.ToTable("Customer");
  64. entity.Property(e => e.Id).ValueGeneratedNever();
  65. entity.Property(e => e.ApiCustomerId).HasMaxLength(36);
  66. entity.Property(e => e.ApiKey).HasMaxLength(128);
  67. entity.Property(e => e.ApiKeyUpdatedOn).HasColumnType("datetime");
  68. entity.Property(e => e.ApiUrl).HasMaxLength(256);
  69. entity.Property(e => e.CreatedBy).HasMaxLength(50);
  70. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  71. entity.Property(e => e.Deadline).HasColumnType("datetime");
  72. entity.Property(e => e.EnableTtia).HasColumnName("EnableTTIA");
  73. entity.Property(e => e.Ftphost)
  74. .HasMaxLength(50)
  75. .HasColumnName("FTPHost");
  76. entity.Property(e => e.Ftppassword)
  77. .HasMaxLength(20)
  78. .HasColumnName("FTPPassword");
  79. entity.Property(e => e.Ftppath).HasColumnName("FTPPath");
  80. entity.Property(e => e.Ftpuser)
  81. .HasMaxLength(20)
  82. .HasColumnName("FTPUser");
  83. entity.Property(e => e.Name).HasMaxLength(50);
  84. entity.Property(e => e.PartnerId).HasMaxLength(36);
  85. entity.Property(e => e.TtiaApikey)
  86. .HasMaxLength(10)
  87. .HasColumnName("TTIA_APIKey");
  88. entity.Property(e => e.TtiaApiurl)
  89. .HasMaxLength(100)
  90. .HasColumnName("TTIA_APIUrl");
  91. entity.Property(e => e.TtiaCustomerId).HasColumnName("TTIA_CustomerId");
  92. entity.Property(e => e.TtiaEquipmentProvider)
  93. .HasMaxLength(10)
  94. .HasColumnName("TTIA_EquipmentProvider");
  95. entity.Property(e => e.UpdatedBy).HasMaxLength(50);
  96. entity.Property(e => e.UpdatedOn).HasColumnType("datetime");
  97. });
  98. modelBuilder.Entity<LoadingBalance>(entity =>
  99. {
  100. entity.ToTable("LoadingBalance");
  101. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  102. entity.Property(e => e.FinishedOn).HasColumnType("datetime");
  103. entity.Property(e => e.MachineId)
  104. .IsRequired()
  105. .HasMaxLength(36);
  106. entity.Property(e => e.Power).HasColumnType("decimal(10, 2)");
  107. });
  108. modelBuilder.Entity<Machine>(entity =>
  109. {
  110. entity.HasKey(e => e.Id).HasName("PK_dbo.Machine");
  111. entity.ToTable("Machine");
  112. entity.HasIndex(e => new { e.CustomerId, e.ChargeBoxId }, "nci_wi_Machine_7CD4A9D1688F96F6967B2244A0666F62");
  113. entity.Property(e => e.Id).HasMaxLength(36);
  114. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  115. entity.Property(e => e.ChargeBoxSerialNumber).HasMaxLength(25);
  116. entity.Property(e => e.ChargePointModel).HasMaxLength(20);
  117. entity.Property(e => e.ChargePointSerialNumber).HasMaxLength(25);
  118. entity.Property(e => e.ChargePointVendor).HasMaxLength(20);
  119. entity.Property(e => e.Comment).HasMaxLength(100);
  120. entity.Property(e => e.ConnectorPowerType).HasMaxLength(50);
  121. entity.Property(e => e.ConnectorType).HasMaxLength(50);
  122. entity.Property(e => e.CreatedBy).HasMaxLength(50);
  123. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  124. entity.Property(e => e.FwAssignedVersion).HasColumnName("FW_AssignedVersion");
  125. entity.Property(e => e.FwCurrentVersion)
  126. .HasMaxLength(50)
  127. .HasColumnName("FW_CurrentVersion");
  128. entity.Property(e => e.FwVersionReport).HasColumnName("FW_VersionReport");
  129. entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime");
  130. entity.Property(e => e.Iccid).HasMaxLength(20);
  131. entity.Property(e => e.Imsi).HasMaxLength(20);
  132. entity.Property(e => e.Latitude).HasColumnType("decimal(10, 6)");
  133. entity.Property(e => e.Longitude).HasColumnType("decimal(10, 6)");
  134. entity.Property(e => e.MeterSerialNumber).HasMaxLength(25);
  135. entity.Property(e => e.MeterType).HasMaxLength(25);
  136. entity.Property(e => e.ModelName)
  137. .IsRequired()
  138. .HasMaxLength(50)
  139. .HasDefaultValueSql("('')");
  140. entity.Property(e => e.OfflineOn).HasColumnType("datetime");
  141. entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)");
  142. entity.Property(e => e.Ttiatag).HasColumnName("TTIATag");
  143. entity.Property(e => e.VendorId)
  144. .HasMaxLength(50)
  145. .HasDefaultValueSql("('Zerova')");
  146. entity.HasOne(d => d.Customer).WithMany(p => p.Machines)
  147. .HasForeignKey(d => d.CustomerId)
  148. .HasConstraintName("FK_dbo.Machine_dbo.Customer_CustomerId");
  149. });
  150. modelBuilder.Entity<MachineConfiguration>(entity =>
  151. {
  152. entity.HasKey(e => new { e.ConfigureName, e.ChargeBoxId }).HasName("PK_dbo.MachineConfigurations");
  153. entity.HasIndex(e => new { e.ConfigureName, e.ConfigureSetting }, "nci_wi_MachineConfigurations_132E765C043BF95A2570D2EA019DD783");
  154. entity.Property(e => e.ConfigureName).HasMaxLength(50);
  155. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  156. entity.Property(e => e.ConfigureSetting).HasMaxLength(500);
  157. entity.Property(e => e.Id).ValueGeneratedOnAdd();
  158. });
  159. modelBuilder.Entity<MachineError>(entity =>
  160. {
  161. entity.HasKey(e => e.Id).HasName("PK_dbo.MachineError");
  162. entity.ToTable("MachineError");
  163. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  164. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  165. entity.Property(e => e.ErrorInfo).HasMaxLength(50);
  166. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  167. entity.Property(e => e.VendorId).HasMaxLength(255);
  168. });
  169. modelBuilder.Entity<MachineOperateRecord>(entity =>
  170. {
  171. entity.HasKey(e => e.Id).HasName("PK_dbo.MachineOperateRecord");
  172. entity.ToTable("MachineOperateRecord");
  173. entity.Property(e => e.Action).HasMaxLength(30);
  174. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  175. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  176. entity.Property(e => e.EvseStatus).HasColumnName("EVSE_Status");
  177. entity.Property(e => e.EvseValue).HasColumnName("EVSE_Value");
  178. entity.Property(e => e.FinishedOn).HasColumnType("datetime");
  179. entity.Property(e => e.ReportedOn).HasColumnType("datetime");
  180. entity.Property(e => e.SerialNo).HasMaxLength(36);
  181. });
  182. modelBuilder.Entity<MachineVersionFile>(entity =>
  183. {
  184. entity.HasKey(e => e.Id).HasName("PK_dbo.MachineVersionFile");
  185. entity.ToTable("MachineVersionFile");
  186. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  187. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  188. entity.Property(e => e.UploadFileId)
  189. .IsRequired()
  190. .HasMaxLength(36);
  191. entity.HasOne(d => d.UploadFile).WithMany(p => p.MachineVersionFiles)
  192. .HasForeignKey(d => d.UploadFileId)
  193. .HasConstraintName("FK_dbo.MachineVersionFile_dbo.UploadFile_UploadFileId");
  194. });
  195. modelBuilder.Entity<MigrationHistory>(entity =>
  196. {
  197. entity.HasKey(e => new { e.MigrationId, e.ContextKey }).HasName("PK_dbo.__MigrationHistory");
  198. entity.ToTable("__MigrationHistory");
  199. entity.Property(e => e.MigrationId).HasMaxLength(150);
  200. entity.Property(e => e.ContextKey).HasMaxLength(300);
  201. entity.Property(e => e.Model).IsRequired();
  202. entity.Property(e => e.ProductVersion)
  203. .IsRequired()
  204. .HasMaxLength(32);
  205. });
  206. modelBuilder.Entity<Ocmf>(entity =>
  207. {
  208. entity.HasKey(e => e.Id).HasName("PK_dbo.OCMF");
  209. entity.ToTable("OCMF");
  210. entity.Property(e => e.DataString).HasMaxLength(2048);
  211. entity.Property(e => e.PublicKey).HasMaxLength(256);
  212. });
  213. modelBuilder.Entity<ServerMessage>(entity =>
  214. {
  215. entity.HasKey(e => e.Id).HasName("PK_dbo.ServerMessage");
  216. entity.ToTable("ServerMessage");
  217. entity.HasIndex(e => new { e.ReceivedOn, e.UpdatedOn, e.CreatedOn }, "nci_wi_ServerMessage_EC00C205420F6CB01974705B93F9507F");
  218. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  219. entity.Property(e => e.CreatedBy).HasMaxLength(36);
  220. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  221. entity.Property(e => e.OutAction).HasMaxLength(30);
  222. entity.Property(e => e.ReceivedOn).HasColumnType("datetime");
  223. entity.Property(e => e.SerialNo).HasMaxLength(36);
  224. entity.Property(e => e.UpdatedOn).HasColumnType("datetime");
  225. });
  226. modelBuilder.Entity<TransactionRecord>(entity =>
  227. {
  228. entity.HasKey(e => e.Id).HasName("PK_dbo.TransactionRecord");
  229. entity.ToTable("TransactionRecord");
  230. entity.HasIndex(e => new { e.CustomerId, e.ConnectorId, e.StartTime, e.ChargeBoxId }, "IX_TransactionRecord_StartTime");
  231. entity.HasIndex(e => new { e.CustomerId, e.StopTransactionReportedOn, e.StopTime }, "nci_wi_TransactionRecord_92D4DF08E7034102014AC91760F890FE");
  232. entity.Property(e => e.ChargeBoxId)
  233. .IsRequired()
  234. .HasMaxLength(50);
  235. entity.Property(e => e.Cost).HasColumnType("decimal(18, 2)");
  236. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  237. entity.Property(e => e.Evccid)
  238. .HasMaxLength(30)
  239. .HasColumnName("EVCCID");
  240. entity.Property(e => e.Fee).HasMaxLength(1500);
  241. entity.Property(e => e.MeterStart).HasColumnType("decimal(18, 2)");
  242. entity.Property(e => e.MeterStop).HasColumnType("decimal(18, 2)");
  243. entity.Property(e => e.Receipt).HasMaxLength(3000);
  244. entity.Property(e => e.StartIdTag).HasMaxLength(20);
  245. entity.Property(e => e.StartSoc)
  246. .HasMaxLength(3)
  247. .HasColumnName("StartSOC");
  248. entity.Property(e => e.StartTime).HasColumnType("datetime");
  249. entity.Property(e => e.StartTransactionReportedOn).HasColumnType("datetime");
  250. entity.Property(e => e.StopIdTag).HasMaxLength(20);
  251. entity.Property(e => e.StopReason).HasMaxLength(60);
  252. entity.Property(e => e.StopSoc)
  253. .HasMaxLength(3)
  254. .HasColumnName("StopSOC");
  255. entity.Property(e => e.StopTime).HasColumnType("datetime");
  256. entity.Property(e => e.StopTransactionReportedOn).HasColumnType("datetime");
  257. entity.Property(e => e.UpdatedOn).HasColumnType("datetime");
  258. entity.Property(e => e.UploadedtoTtia).HasColumnName("UploadedtoTTIA");
  259. });
  260. modelBuilder.Entity<UploadFile>(entity =>
  261. {
  262. entity.HasKey(e => e.Id).HasName("PK_dbo.UploadFile");
  263. entity.ToTable("UploadFile");
  264. entity.Property(e => e.Id).HasMaxLength(36);
  265. entity.Property(e => e.CreatedBy).HasMaxLength(50);
  266. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  267. entity.Property(e => e.FileExtensionName).HasMaxLength(50);
  268. entity.Property(e => e.FileMd5)
  269. .HasMaxLength(50)
  270. .HasColumnName("FileMD5");
  271. entity.Property(e => e.FileName)
  272. .IsRequired()
  273. .HasMaxLength(500);
  274. entity.Property(e => e.FilePath)
  275. .IsRequired()
  276. .HasMaxLength(500);
  277. entity.Property(e => e.FileType).HasMaxLength(200);
  278. entity.Property(e => e.FileUrl).HasMaxLength(512);
  279. entity.Property(e => e.ModelName)
  280. .IsRequired()
  281. .HasMaxLength(50);
  282. entity.Property(e => e.OriginName)
  283. .IsRequired()
  284. .HasMaxLength(500);
  285. entity.Property(e => e.VendorId)
  286. .IsRequired()
  287. .HasMaxLength(50);
  288. });
  289. modelBuilder.Entity<VConnectorStatus>(entity =>
  290. {
  291. entity
  292. .HasNoKey()
  293. .ToView("vConnectorStatus");
  294. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  295. entity.Property(e => e.CreatedOn).HasColumnType("datetime");
  296. entity.Property(e => e.ErrorInfo).HasMaxLength(50);
  297. entity.Property(e => e.Id)
  298. .IsRequired()
  299. .HasMaxLength(36);
  300. entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)");
  301. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  302. entity.Property(e => e.VendorId).HasMaxLength(255);
  303. });
  304. modelBuilder.Entity<VConnectorStatusCombind>(entity =>
  305. {
  306. entity
  307. .HasNoKey()
  308. .ToView("vConnectorStatusCombind");
  309. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  310. entity.Property(e => e.Ocpp)
  311. .IsRequired()
  312. .HasMaxLength(3)
  313. .IsUnicode(false)
  314. .HasColumnName("OCPP");
  315. entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)");
  316. entity.Property(e => e.VendorErrorCode).HasMaxLength(100);
  317. });
  318. modelBuilder.Entity<VMachine>(entity =>
  319. {
  320. entity
  321. .HasNoKey()
  322. .ToView("vMachine");
  323. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  324. entity.Property(e => e.ConnectorType).HasMaxLength(50);
  325. entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime");
  326. entity.Property(e => e.Id)
  327. .IsRequired()
  328. .HasMaxLength(36);
  329. entity.Property(e => e.ModelName)
  330. .IsRequired()
  331. .HasMaxLength(50);
  332. entity.Property(e => e.OfflineOn).HasColumnType("datetime");
  333. entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)");
  334. entity.Property(e => e.Ttiatag).HasColumnName("TTIATag");
  335. entity.Property(e => e.VendorId).HasMaxLength(50);
  336. });
  337. modelBuilder.Entity<VMachineCombind>(entity =>
  338. {
  339. entity
  340. .HasNoKey()
  341. .ToView("vMachineCombind");
  342. entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
  343. entity.Property(e => e.ConnectorType).HasMaxLength(50);
  344. entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime");
  345. entity.Property(e => e.Id)
  346. .IsRequired()
  347. .HasMaxLength(36);
  348. entity.Property(e => e.ModelName)
  349. .IsRequired()
  350. .HasMaxLength(50);
  351. entity.Property(e => e.Ocpp)
  352. .IsRequired()
  353. .HasMaxLength(3)
  354. .IsUnicode(false)
  355. .HasColumnName("OCPP");
  356. entity.Property(e => e.OfflineOn).HasColumnType("datetime");
  357. entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)");
  358. entity.Property(e => e.Ttiatag).HasColumnName("TTIATag");
  359. entity.Property(e => e.VendorId).HasMaxLength(50);
  360. });
  361. OnModelCreatingPartial(modelBuilder);
  362. }
  363. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  364. }