Răsfoiți Sursa

Update comm dll

Robert 1 an în urmă
părinte
comite
9ab21b29bd

+ 2 - 2
Dev_Build.bat

@@ -1,3 +1,3 @@
 for /f %%i in ('git rev-parse --short HEAD') do set ssha=%%i
-docker build ./ -t evdevcontainerregistry.azurecr.io/server:test --label "git-commit=%ssha%"
-docker push evdevcontainerregistry.azurecr.io/server:test
+docker build ./ -t evdevcontainerregistry.azurecr.io/nginx-reverse-proxy:test --label "git-commit=%ssha%"
+docker push evdevcontainerregistry.azurecr.io/nginx-reverse-proxy:test

BIN
EVCB_OCPP.WSServer/DLL/EVCB_OCPP.Domain.dll


+ 2 - 1
EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj

@@ -41,7 +41,8 @@
   </ItemGroup>
   <ItemGroup>
     <PackageReference Include="Dapper" Version="2.0.143" />
-    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.12" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
     <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />

+ 7 - 8
EVCB_OCPP.WSServer/Helper/AddPortalDbContext.cs

@@ -9,7 +9,6 @@ using NLog.Extensions.Logging;
 using System;
 using System.Collections.Generic;
 using System.Configuration;
-using System.Data.Entity.Infrastructure;
 using System.Diagnostics;
 using System.Linq;
 using System.Text;
@@ -30,7 +29,7 @@ public static class AddPortalDbContext
 
         services.AddSingleton(
             (serviceProvider) =>
-            new SqlConnectionFactory<MainDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory>>())
+            new SqlConnectionFactory<MainDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory<MainDBContext>>>())
             {
                 ConnectionString = conneciotnString
             });
@@ -47,7 +46,7 @@ public static class AddPortalDbContext
         var conneciotnString = GetConnectionString(configuration, DbUserIdKey, DbPassKey, DbConnectionStringKey);
         services.AddSingleton(
             (serviceProvider) =>
-            new SqlConnectionFactory<MeterValueDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory>>())
+            new SqlConnectionFactory<MeterValueDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory<MeterValueDBContext>>>())
             {
                 ConnectionString = conneciotnString
             });
@@ -64,7 +63,7 @@ public static class AddPortalDbContext
         var conneciotnString = GetConnectionString(configuration, DbUserIdKey, DbPassKey, DbConnectionStringKey);
         services.AddSingleton(
             (serviceProvider) =>
-            new SqlConnectionFactory<ConnectionLogDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory>>())
+            new SqlConnectionFactory<ConnectionLogDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory<ConnectionLogDBContext>>>())
             {
                 ConnectionString = conneciotnString
             });
@@ -81,7 +80,7 @@ public static class AddPortalDbContext
         var conneciotnString = GetConnectionString(configuration, DbUserIdKey, DbPassKey, DbConnectionStringKey);
         services.AddSingleton(
             (serviceProvider) =>
-            new SqlConnectionFactory<WebDBConetext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory>>())
+            new SqlConnectionFactory<WebDBConetext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory<WebDBConetext>>>())
             {
                 ConnectionString = conneciotnString
             });
@@ -97,7 +96,7 @@ public static class AddPortalDbContext
         var conneciotnString = GetConnectionString(configuration, DbUserIdKey, DbPassKey, DbConnectionStringKey);
         services.AddSingleton(
             (serviceProvider) =>
-            new SqlConnectionFactory<OnlineLogDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory>>())
+            new SqlConnectionFactory<OnlineLogDBContext>(serviceProvider.GetRequiredService<ILogger<SqlConnectionFactory<OnlineLogDBContext>>>())
             {
                 ConnectionString = conneciotnString
             });
@@ -130,10 +129,10 @@ public static class AddPortalDbContext
 
 public class SqlConnectionFactory<T> where T: DbContext
 {
-    private readonly ILogger<SqlConnectionFactory> logger;
+    private readonly ILogger<SqlConnectionFactory<T>> logger;
 
     public string ConnectionString { get; init; }
-    public SqlConnectionFactory(ILogger<SqlConnectionFactory> logger)
+    public SqlConnectionFactory(ILogger<SqlConnectionFactory<T>> logger)
     {
         this.logger = logger;
     }

+ 1 - 1
EVCB_OCPP.WSServer/Jobs/HeartBeatCheckJob.cs

@@ -1,5 +1,5 @@
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
+using EVCB_OCPP.Domain.Models.MainDb;
 using EVCB_OCPP.WSServer.Service;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Logging;

+ 3 - 3
EVCB_OCPP.WSServer/Jobs/ServerMessageJob.cs

@@ -1,5 +1,5 @@
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
+using EVCB_OCPP.Domain.Models.MainDb;
 using EVCB_OCPP.Packet.Features;
 using EVCB_OCPP.Packet.Messages;
 using EVCB_OCPP.WSServer.Message;
@@ -63,7 +63,7 @@ public class ServerMessageJob : IJob
 
         using (var db = await maindbContextFactory.CreateDbContextAsync())
         {
-            commandList = await db.ServerMessage.Where(c => c.ReceivedOn == dt && c.UpdatedOn == dt && c.CreatedOn >= startDt && c.CreatedOn <= currentTime).AsNoTracking().ToListAsync();
+            commandList = await db.ServerMessages.Where(c => c.ReceivedOn == dt && c.UpdatedOn == dt && c.CreatedOn >= startDt && c.CreatedOn <= currentTime).AsNoTracking().ToListAsync();
         }
         //處理主機傳送的有指令
         var cmdMachineList = commandList.Select(c => c.ChargeBoxId).Distinct().ToList();
@@ -165,7 +165,7 @@ public class ServerMessageJob : IJob
 
                     using (var db = await maindbContextFactory.CreateDbContextAsync())
                     {
-                        db.ServerMessage.Attach(_UpdatedItem);
+                        db.ServerMessages.Attach(_UpdatedItem);
                         _UpdatedItem.UpdatedOn = dateTimeNow;
                         db.Entry(_UpdatedItem).Property(x => x.UpdatedOn).IsModified = true;// 可以直接使用這方式強制某欄位要更新,只是查詢集合耗效能而己
 

+ 0 - 1
EVCB_OCPP.WSServer/Jobs/ServerSetFeeJob.cs

@@ -1,6 +1,5 @@
 using Dapper;
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
 using EVCB_OCPP.Packet.Features;
 using EVCB_OCPP.Packet.Messages.Core;
 using EVCB_OCPP.WSServer.Dto;

+ 3 - 3
EVCB_OCPP.WSServer/Jobs/ServerUpdateJob.cs

@@ -44,8 +44,8 @@ public class ServerUpdateJob : IJob
             //    x.FW_AssignedMachineVersionId != x.FW_VersionReport && x.Online == true)
             //    .Select(x => new { x.Id, x.ChargeBoxId, x.FW_AssignedMachineVersionId }).ToList();
 
-            needUpdateChargers = await db.Machine.Where(x => x.FW_AssignedVersion.HasValue == true &&
-              x.FW_AssignedVersion != x.FW_VersionReport && x.Online == true)
+            needUpdateChargers = await db.Machines.Where(x => x.FwAssignedVersion.HasValue == true &&
+              x.FwAssignedVersion != x.FwVersionReport && x.Online == true)
               .Select(x => x.ChargeBoxId).AsNoTracking().ToListAsync();
         }
 
@@ -95,7 +95,7 @@ public class ServerUpdateJob : IJob
                         //            retrieveDate = DateTime.UtcNow,
                         //            retryInterval = 10
                         //        };
-                        //        db.MachineOperateRecord.Add(new MachineOperateRecord()
+                        //        db.MachineOperateRecords.Add(new MachineOperateRecord()
                         //        {
                         //            CreatedOn = DateTime.UtcNow,
                         //            ChargeBoxId = session.ChargeBoxId,

+ 38 - 38
EVCB_OCPP.WSServer/Message/CoreProfileHandler.cs

@@ -1,6 +1,5 @@
 using Dapper;
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
 using EVCB_OCPP.Packet.Features;
 using EVCB_OCPP.Packet.Messages;
 using EVCB_OCPP.Packet.Messages.Core;
@@ -20,6 +19,7 @@ using System.Diagnostics;
 using System.Globalization;
 using SuperSocket.SocketBase;
 using Microsoft.AspNetCore.Http;
+using EVCB_OCPP.Domain.Models.MainDb;
 
 namespace EVCB_OCPP.WSServer.Message;
 
@@ -187,7 +187,7 @@ internal partial class ProfileHandler
 
                             logger.LogDebug("{0}\r\n{1}\r\n{2}", jo["txId"].Value<int>(), jo["dataString"].Value<string>(), jo["publicKey"].Value<string>());
 
-                            await mainDbService.AddOCMF(new OCMF()
+                            await mainDbService.AddOCMF(new Ocmf()
                             {
                                 TransactionId = jo["txId"].Value<int>(),
                                 DataString = jo["dataString"].Value<string>(),
@@ -229,7 +229,7 @@ internal partial class ProfileHandler
                         _machine.ChargePointSerialNumber = string.IsNullOrEmpty(_request.chargePointSerialNumber) ? string.Empty : _request.chargePointSerialNumber;
                         _machine.ChargePointModel = string.IsNullOrEmpty(_request.chargePointModel) ? string.Empty : _request.chargePointModel;
                         _machine.ChargePointVendor = string.IsNullOrEmpty(_request.chargePointVendor) ? string.Empty : _request.chargePointVendor;
-                        _machine.FW_CurrentVersion = string.IsNullOrEmpty(_request.firmwareVersion) ? string.Empty : _request.firmwareVersion;
+                        _machine.FwCurrentVersion = string.IsNullOrEmpty(_request.firmwareVersion) ? string.Empty : _request.firmwareVersion;
                         //_machine.Iccid = string.IsNullOrEmpty(_request.iccid) ? string.Empty : _request.iccid;
                         _machine.Iccid = DateTime.UtcNow.ToString("yy-MM-dd HH:mm");
                         _machine.Imsi = string.IsNullOrEmpty(_request.imsi) ? string.Empty : _request.imsi;
@@ -383,7 +383,7 @@ internal partial class ProfileHandler
 
                                         using (var maindb = await maindbContextFactory.CreateDbContextAsync())
                                         {
-                                            meterStart = await maindb.TransactionRecord
+                                            meterStart = await maindb.TransactionRecords
                                                 .Where(x => x.Id == _request.transactionId.Value).Select(x => x.MeterStart)
                                                 .FirstOrDefaultAsync();
                                         }
@@ -956,14 +956,14 @@ internal partial class ProfileHandler
                         DataTransferRequest _request = _confirm.GetRequest() as DataTransferRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = string.IsNullOrEmpty(_confirm.data) ? "" : _confirm.data;
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = string.IsNullOrEmpty(_confirm.data) ? "" : _confirm.data;
                                 await db.SaveChangesAsync();
                             }
 
@@ -974,7 +974,7 @@ internal partial class ProfileHandler
                                 {
                                     db.ChangeTracker.AutoDetectChangesEnabled = false;
                                     //db.Configuration.ValidateOnSaveEnabled = false;
-                                    db.Machine.Attach(machine);
+                                    db.Machines.Attach(machine);
                                     machine.BoardVersions = _confirm.data;
                                     db.Entry(machine).Property(x => x.BoardVersions).IsModified = true;
                                     await db.SaveChangesAsync();
@@ -991,7 +991,7 @@ internal partial class ProfileHandler
                                     List<ChargingBill> bill = new List<ChargingBill>();
                                     List<ChargingPrice> chargingPrices = new List<ChargingPrice>();
                                     var txEnergy = JsonConvert.DeserializeObject<TransactionEnergy>(_confirm.data);
-                                    var feedto = await db.TransactionRecord.Where(x => x.Id == txEnergy.TxId).Select(x => new { Id = x.Id, ConnectorId = x.ConnectorId, Fee = x.Fee, StopTime = x.StopTime, StartTime = x.StartTime }).FirstOrDefaultAsync();
+                                    var feedto = await db.TransactionRecords.Where(x => x.Id == txEnergy.TxId).Select(x => new { Id = x.Id, ConnectorId = x.ConnectorId, Fee = x.Fee, StopTime = x.StopTime, StartTime = x.StartTime }).FirstOrDefaultAsync();
                                     decimal chargedEnergy = 0m;
                                     if (feedto == null || string.IsNullOrEmpty(feedto.Fee)) return result;
                                     string currency = feedto.Fee.Substring(feedto.Fee.Length - 3);
@@ -1086,7 +1086,7 @@ internal partial class ProfileHandler
                                         decimal accountBalance = 0;
                                         decimal.TryParse(feedto.Fee.Split('+')[1], out accountBalance);
 
-                                        var tx = await db.TransactionRecord.Where(x => x.Id == txEnergy.TxId).FirstOrDefaultAsync();
+                                        var tx = await db.TransactionRecords.Where(x => x.Id == txEnergy.TxId).FirstOrDefaultAsync();
                                         if (tx == null)
                                         {
                                             logger.LogTrace("Tx is empty");
@@ -1205,7 +1205,7 @@ internal partial class ProfileHandler
                                         tx.BillingDone = true;
                                         db.ChangeTracker.AutoDetectChangesEnabled = false;
                                         //db.Configuration.ValidateOnSaveEnabled = false;
-                                        db.TransactionRecord.Attach(tx);
+                                        db.TransactionRecords.Attach(tx);
                                         db.Entry(tx).Property(x => x.Cost).IsModified = true;
                                         db.Entry(tx).Property(x => x.Receipt).IsModified = true;
                                         db.Entry(tx).Property(x => x.BillingDone).IsModified = true;
@@ -1361,14 +1361,14 @@ internal partial class ProfileHandler
 
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -1382,14 +1382,14 @@ internal partial class ProfileHandler
 
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -1403,14 +1403,14 @@ internal partial class ProfileHandler
 
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -1424,14 +1424,14 @@ internal partial class ProfileHandler
 
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -1445,14 +1445,14 @@ internal partial class ProfileHandler
 
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -1466,15 +1466,15 @@ internal partial class ProfileHandler
 
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                      x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
 
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = _confirm.status.ToString();
 
                             }
 
@@ -1581,15 +1581,15 @@ internal partial class ProfileHandler
                                     }
                                 }
 
-                                var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                                var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                                x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
 
                                 if (operation != null)
                                 {
                                     operation.FinishedOn = DateTime.UtcNow;
                                     operation.Status = 1;//電樁有回覆
-                                    operation.EVSE_Status = 1;
-                                    operation.EVSE_Value = JsonConvert.SerializeObject(_confirm.configurationKey, Formatting.None);
+                                    operation.EvseStatus = 1;
+                                    operation.EvseValue = JsonConvert.SerializeObject(_confirm.configurationKey, Formatting.None);
 
                                 }
 
@@ -1611,14 +1611,14 @@ internal partial class ProfileHandler
 
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -1666,14 +1666,14 @@ internal partial class ProfileHandler
 
                     using (var db = await maindbContextFactory.CreateDbContextAsync())
                     {
-                        var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                        var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                         x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                         if (operation != null)
                         {
                             operation.FinishedOn = DateTime.UtcNow;
                             operation.Status = 1;//電樁有回覆
-                            operation.EVSE_Status = (int)255;//錯誤
-                            operation.EVSE_Value = errorMsg;
+                            operation.EvseStatus = (int)255;//錯誤
+                            operation.EvseValue = errorMsg;
                             await db.SaveChangesAsync();
                         }
 

+ 21 - 21
EVCB_OCPP.WSServer/Message/FirmwareManagementProfileHandler.cs

@@ -1,5 +1,4 @@
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
 using EVCB_OCPP.Packet.Features;
 using EVCB_OCPP.Packet.Messages;
 using EVCB_OCPP.Packet.Messages.FirmwareManagement;
@@ -10,6 +9,7 @@ using System.Linq;
 using Microsoft.Extensions.Logging;
 using System.Threading.Tasks;
 using Microsoft.EntityFrameworkCore;
+using EVCB_OCPP.Domain.Models.MainDb;
 
 namespace EVCB_OCPP.WSServer.Message
 {
@@ -32,14 +32,14 @@ namespace EVCB_OCPP.WSServer.Message
                                 string requestId = Guid.NewGuid().ToString();
                                 using (var db = await maindbContextFactory.CreateDbContextAsync())
                                 {
-                                    var machine = await db.Machine.Where(x => x.FW_AssignedVersion.HasValue == true && x.FW_AssignedVersion.HasValue
-                                       && x.FW_AssignedVersion != x.FW_VersionReport && x.ChargeBoxId == session.ChargeBoxId)
-                                        .Select(x => new { x.Id, x.FW_AssignedVersion }).AsNoTracking().FirstOrDefaultAsync();
+                                    var machine = await db.Machines.Where(x => x.FwAssignedVersion.HasValue == true && x.FwAssignedVersion.HasValue
+                                       && x.FwAssignedVersion != x.FwVersionReport && x.ChargeBoxId == session.ChargeBoxId)
+                                        .Select(x => new { x.Id, x.FwAssignedVersion }).AsNoTracking().FirstOrDefaultAsync();
 
                                     if (machine != null)
                                     {
-                                        var mv = db.MachineVersionFile.Include(c => c.UploadFile)
-                                         .Where(c => c.Id == machine.FW_AssignedVersion.Value).First();
+                                        var mv = db.MachineVersionFiles.Include(c => c.UploadFile)
+                                         .Where(c => c.Id == machine.FwAssignedVersion.Value).First();
 
                                         string downloadUrl = mv.UploadFile.FileUrl;
 
@@ -51,14 +51,14 @@ namespace EVCB_OCPP.WSServer.Message
                                             retryInterval = 10
                                         };
 
-                                        await db.MachineOperateRecord.AddAsync(new MachineOperateRecord()
+                                        await db.MachineOperateRecords.AddAsync(new MachineOperateRecord()
                                         {
                                             CreatedOn = DateTime.UtcNow,
                                             ChargeBoxId = session.ChargeBoxId,
                                             SerialNo = requestId,
                                             RequestContent = JsonConvert.SerializeObject(_updateFWrequest, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
-                                            EVSE_Status = 0,
-                                            EVSE_Value = "Fw Version:" + machine.FW_AssignedVersion,
+                                            EvseStatus = 0,
+                                            EvseValue = "Fw Version:" + machine.FwAssignedVersion,
                                             Status = 0,
                                             RequestType = 0,
                                             Action = _updateFWrequest.Action.ToString()
@@ -73,8 +73,8 @@ namespace EVCB_OCPP.WSServer.Message
                                             OutRequest: _updateFWrequest,
                                             SerialNo: requestId);
 
-                                        var clearMachine = await db.Machine.Where(x => x.Id == machine.Id).FirstOrDefaultAsync();
-                                        clearMachine.FW_AssignedVersion = null;
+                                        var clearMachine = await db.Machines.Where(x => x.Id == machine.Id).FirstOrDefaultAsync();
+                                        clearMachine.FwAssignedVersion = null;
                                         await db.SaveChangesAsync();
                                     }
 
@@ -84,17 +84,17 @@ namespace EVCB_OCPP.WSServer.Message
                             {
                                 using (var db = await maindbContextFactory.CreateDbContextAsync())
                                 {
-                                    var item = await db.MachineOperateRecord.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.RequestType == 0)
+                                    var item = await db.MachineOperateRecords.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.RequestType == 0)
                                         .OrderByDescending(x => x.CreatedOn).FirstOrDefaultAsync();
                                     if (item != null)
                                     {
-                                        item.EVSE_Status = (int)_request.status;
+                                        item.EvseStatus = (int)_request.status;
                                         item.FinishedOn = DateTime.UtcNow;
 
-                                        //if (!string.IsNullOrEmpty(item.EVSE_Value) && _request.status == Packet.Messages.SubTypes.FirmwareStatus.Installed)
+                                        //if (!string.IsNullOrEmpty(item.EvseValue) && _request.status == Packet.Messages.SubTypes.FirmwareStatus.Installed)
                                         //{
                                         //    int version = 0;
-                                        //    int.TryParse(item.EVSE_Value.Split(':').Last(), out version);
+                                        //    int.TryParse(item.EvseValue.Split(':').Last(), out version);
                                         //    var machine = await db.Machine.Where(x => x.ChargeBoxId == session.ChargeBoxId).FirstOrDefaultAsync();
                                         //    machine.FW_VersionReport = version;
                                         //}
@@ -156,15 +156,15 @@ namespace EVCB_OCPP.WSServer.Message
                         }
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord
+                            var operation = await db.MachineOperateRecords
                                 .Where(x => x.SerialNo == requestId && x.ChargeBoxId == session.ChargeBoxId && x.Status == 0)
                                 .FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)1;//OK
-                                operation.EVSE_Value = string.IsNullOrEmpty(evse_rep) ? operation.EVSE_Value : evse_rep;
+                                operation.EvseStatus = (int)1;//OK
+                                operation.EvseValue = string.IsNullOrEmpty(evse_rep) ? operation.EvseValue : evse_rep;
                                 await db.SaveChangesAsync();
                             }
 
@@ -194,15 +194,15 @@ namespace EVCB_OCPP.WSServer.Message
                     {
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord
+                            var operation = await db.MachineOperateRecords
                                 .Where(x => x.SerialNo == requestId && x.ChargeBoxId == session.ChargeBoxId && x.Status == 0)
                                 .FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)255;//錯誤
-                                operation.EVSE_Value = errorMsg;
+                                operation.EvseStatus = (int)255;//錯誤
+                                operation.EvseValue = errorMsg;
                                 await db.SaveChangesAsync();
                             }
 

+ 9 - 9
EVCB_OCPP.WSServer/Message/LocalAuthListManagementProfileHandler.cs

@@ -25,14 +25,14 @@ namespace EVCB_OCPP.WSServer.Message
                         GetLocalListVersionRequest _request = _confirm.GetRequest() as GetLocalListVersionRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = 1;//OK
-                                operation.EVSE_Value = _confirm.listVersion.ToString();
+                                operation.EvseStatus = 1;//OK
+                                operation.EvseValue = _confirm.listVersion.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -45,14 +45,14 @@ namespace EVCB_OCPP.WSServer.Message
                         SendLocalListRequest _request = _confirm.GetRequest() as SendLocalListRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;//OK     
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;//OK     
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -80,14 +80,14 @@ namespace EVCB_OCPP.WSServer.Message
                     {
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)255;//錯誤
-                                operation.EVSE_Value = errorMsg;
+                                operation.EvseStatus = (int)255;//錯誤
+                                operation.EvseValue = errorMsg;
                                 await db.SaveChangesAsync();
                             }
 

+ 6 - 6
EVCB_OCPP.WSServer/Message/RemoteTriggerHandler.cs

@@ -27,14 +27,14 @@ namespace EVCB_OCPP.WSServer.Message
                         TriggerMessageRequest _request = _confirm.GetRequest() as TriggerMessageRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;//OK
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;//OK
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -61,14 +61,14 @@ namespace EVCB_OCPP.WSServer.Message
                     {
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)255;//錯誤
-                                operation.EVSE_Value = errorMsg;
+                                operation.EvseStatus = (int)255;//錯誤
+                                operation.EvseValue = errorMsg;
                                 await db.SaveChangesAsync();
                             }
 

+ 12 - 12
EVCB_OCPP.WSServer/Message/ReservationProfileHandler.cs

@@ -27,14 +27,14 @@ namespace EVCB_OCPP.WSServer.Message
                         ReserveNowRequest _request = _confirm.GetRequest() as ReserveNowRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;//OK
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;//OK
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -47,14 +47,14 @@ namespace EVCB_OCPP.WSServer.Message
                         CancelReservationRequest _request = _confirm.GetRequest() as CancelReservationRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;//OK
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;//OK
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -81,14 +81,14 @@ namespace EVCB_OCPP.WSServer.Message
                     {
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)255;//錯誤
-                                operation.EVSE_Value = errorMsg;
+                                operation.EvseStatus = (int)255;//錯誤
+                                operation.EvseValue = errorMsg;
                                 await db.SaveChangesAsync();
                             }
 
@@ -99,14 +99,14 @@ namespace EVCB_OCPP.WSServer.Message
                     {
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)255;//錯誤
-                                operation.EVSE_Value = errorMsg;
+                                operation.EvseStatus = (int)255;//錯誤
+                                operation.EvseValue = errorMsg;
                                 await db.SaveChangesAsync();
                             }
 

+ 13 - 13
EVCB_OCPP.WSServer/Message/SmartChargingProfileHandler.cs

@@ -1,5 +1,5 @@
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
+using EVCB_OCPP.Domain.Models.MainDb;
 using EVCB_OCPP.Packet.Features;
 using EVCB_OCPP.Packet.Messages;
 using EVCB_OCPP.Packet.Messages.SmartCharging;
@@ -83,14 +83,14 @@ namespace EVCB_OCPP.WSServer.Message
                         ClearChargingProfileRequest _request = _confirm.GetRequest() as ClearChargingProfileRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;//OK
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;//OK
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -103,14 +103,14 @@ namespace EVCB_OCPP.WSServer.Message
                         SetChargingProfileRequest _request = _confirm.GetRequest() as SetChargingProfileRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
+                            var operation = await db.MachineOperateRecords.Where(x => x.SerialNo == requestId &&
                             x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;//OK
-                                operation.EVSE_Value = _confirm.status.ToString();
+                                operation.EvseStatus = (int)_confirm.status;//OK
+                                operation.EvseValue = _confirm.status.ToString();
                                 await db.SaveChangesAsync();
                             }
 
@@ -123,15 +123,15 @@ namespace EVCB_OCPP.WSServer.Message
                         GetCompositeScheduleRequest _request = _confirm.GetRequest() as GetCompositeScheduleRequest;
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord
+                            var operation = await db.MachineOperateRecords
                                 .Where(x => x.SerialNo == requestId && x.ChargeBoxId == session.ChargeBoxId && x.Status == 0)
                                 .FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)_confirm.status;//OK
-                                operation.EVSE_Value = JsonConvert.SerializeObject(_confirm.chargingSchedule, Formatting.None);
+                                operation.EvseStatus = (int)_confirm.status;//OK
+                                operation.EvseValue = JsonConvert.SerializeObject(_confirm.chargingSchedule, Formatting.None);
                                 await db.SaveChangesAsync();
                             }
 
@@ -160,15 +160,15 @@ namespace EVCB_OCPP.WSServer.Message
                     {
                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                         {
-                            var operation = await db.MachineOperateRecord
+                            var operation = await db.MachineOperateRecords
                                 .Where(x => x.SerialNo == requestId && x.ChargeBoxId == session.ChargeBoxId && x.Status == 0)
                                 .FirstOrDefaultAsync();
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
                                 operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)255;//錯誤
-                                operation.EVSE_Value = errorMsg;
+                                operation.EvseStatus = (int)255;//錯誤
+                                operation.EvseValue = errorMsg;
                                 await db.SaveChangesAsync();
                             }
 

+ 3 - 4
EVCB_OCPP.WSServer/ProtalServer.cs

@@ -1,6 +1,5 @@
 using Dapper;
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
 using EVCB_OCPP.Packet.Features;
 using EVCB_OCPP.Packet.Messages;
 using EVCB_OCPP.Packet.Messages.Basic;
@@ -617,7 +616,7 @@ namespace EVCB_OCPP.WSServer
 
                 using (var db = await maindbContextFactory.CreateDbContextAsync())
                 {
-                    var machine = await db.Machine.Where(x => x.ChargeBoxId == session.ChargeBoxId).FirstOrDefaultAsync();
+                    var machine = await db.Machines.Where(x => x.ChargeBoxId == session.ChargeBoxId).FirstOrDefaultAsync();
                     if (machine != null)
                     {
                         machine.ConnectionType = session.Origin.Contains("https") ? 2 : 1;
@@ -940,7 +939,7 @@ namespace EVCB_OCPP.WSServer
                                     {
                                         using (var db = await maindbContextFactory.CreateDbContextAsync())
                                         {
-                                            var machine = await db.Machine.Where(x => x.ChargeBoxId == session.ChargeBoxId).FirstOrDefaultAsync();
+                                            var machine = await db.Machines.Where(x => x.ChargeBoxId == session.ChargeBoxId).FirstOrDefaultAsync();
                                             if (machine != null)
                                             {
                                                 if (machine.ConnectorType.Contains("6") || machine.ConnectorType.Contains("7") || machine.ConnectorType.Contains("8") || machine.ConnectorType.Contains("9"))
@@ -1373,7 +1372,7 @@ namespace EVCB_OCPP.WSServer
 
                     using (var db = await maindbContextFactory.CreateDbContextAsync())
                     {
-                        var sc = await db.ServerMessage.Where(x => x.Id == foundRequest.Id).FirstOrDefaultAsync();
+                        var sc = await db.ServerMessages.Where(x => x.Id == foundRequest.Id).FirstOrDefaultAsync();
                         sc.InMessage = JsonConvert.SerializeObject(analysisResult.Message, Formatting.None);
                         sc.ReceivedOn = DateTime.UtcNow;
                         await db.SaveChangesAsync();

+ 0 - 1
EVCB_OCPP.WSServer/Service/BusinessServiceFactory.cs

@@ -1,5 +1,4 @@
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
 using EVCB_OCPP.Packet.Messages.SubTypes;
 using EVCB_OCPP.WSServer.Dto;
 using Microsoft.EntityFrameworkCore;

+ 1 - 1
EVCB_OCPP.WSServer/Service/ConnectionLogdbService.cs

@@ -60,7 +60,7 @@ public class ConnectionLogdbService : IConnectionLogdbService
         {
             using (var log = connectionLogdbContextFactory.CreateDbContext())
             {
-                log.MachineConnectionLog.ToList();
+                log.MachineConnectionLogs.ToList();
             }
         }
         catch (Exception ex)

+ 24 - 24
EVCB_OCPP.WSServer/Service/MainDbService.cs

@@ -1,6 +1,6 @@
 using Dapper;
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
+using EVCB_OCPP.Domain.Models.MainDb;
 using EVCB_OCPP.WSServer.Helper;
 using Microsoft.Data.SqlClient;
 using Microsoft.EntityFrameworkCore;
@@ -22,7 +22,7 @@ public interface IMainDbService
     Task<MachineAndCustomerInfo> GetMachineIdAndCustomerInfo(string ChargeBoxId);
     Task<string> GetMachineSecurityProfile(string ChargeBoxId);
     Task UpdateMachineBasicInfo(string ChargeBoxId, Machine machine);
-    Task AddOCMF(OCMF oCMF);
+    Task AddOCMF(Ocmf oCMF);
     ValueTask<ConnectorStatus> GetConnectorStatus(string ChargeBoxId, int ConnectorId);
     Task UpdateConnectorStatus(string Id, ConnectorStatus connectorStatus);
     ValueTask AddConnectorStatus(string ChargeBoxId, byte ConnectorId, DateTime CreatedOn, int Status,
@@ -89,7 +89,7 @@ public class MainDbService : IMainDbService
         using var semaphoreWrapper = await startupSemaphore.GetToken();
         using var db = await contextFactory.CreateDbContextAsync();
 
-        var machine = await db.Machine.Where(x => x.ChargeBoxId == ChargeBoxId && x.IsDelete == false).Select(x => new { x.CustomerId, x.Id }).AsNoTracking().FirstOrDefaultAsync();
+        var machine = await db.Machines.Where(x => x.ChargeBoxId == ChargeBoxId && x.IsDelete == false).Select(x => new { x.CustomerId, x.Id }).AsNoTracking().FirstOrDefaultAsync();
         if (machine == null)
         {
             return new MachineAndCustomerInfo(string.Empty, Guid.Empty, "Unknown");
@@ -130,10 +130,10 @@ public class MainDbService : IMainDbService
         return updateMachineBasicInfoHandler.HandleAsync(new UpdateMachineBasicInfoParam(ChargeBoxId, machine));
     }
 
-    public async Task AddOCMF(OCMF oCMF)
+    public async Task AddOCMF(Ocmf oCMF)
     {
         using var db = await contextFactory.CreateDbContextAsync();
-        await db.OCMF.AddAsync(oCMF);
+        await db.Ocmfs.AddAsync(oCMF);
         await db.SaveChangesAsync();
     }
 
@@ -142,7 +142,7 @@ public class MainDbService : IMainDbService
         int ChargePointErrorCodeId, string ErrorInfo, string VendorId, string VendorErrorCode)
     {
         using var db = await contextFactory.CreateDbContextAsync();
-        var _currentStatus = new Domain.Models.Database.ConnectorStatus()
+        var _currentStatus = new ConnectorStatus()
         {
             ChargeBoxId = ChargeBoxId,
             ConnectorId = ConnectorId,
@@ -154,7 +154,7 @@ public class MainDbService : IMainDbService
             VendorErrorCode = VendorErrorCode,
             Id = Guid.NewGuid().ToString()
         };
-        await db.ConnectorStatus.AddAsync(_currentStatus);
+        await db.ConnectorStatuses.AddAsync(_currentStatus);
 
         await db.SaveChangesAsync();
 
@@ -172,7 +172,7 @@ public class MainDbService : IMainDbService
         }
 
         using var db = await contextFactory.CreateDbContextAsync();
-        var statusFromDb = await db.ConnectorStatus.Where(x => x.ChargeBoxId == ChargeBoxId
+        var statusFromDb = await db.ConnectorStatuses.Where(x => x.ChargeBoxId == ChargeBoxId
                             && x.ConnectorId == ConnectorId).AsNoTracking().FirstOrDefaultAsync();
 
         memoryCache.Set(key, statusFromDb, TimeSpan.FromHours(12));
@@ -270,7 +270,7 @@ public class MainDbService : IMainDbService
         Customer toReturn = null;
         using (var db = await contextFactory.CreateDbContextAsync())
         {
-            toReturn = await db.Customer.FirstOrDefaultAsync(x => x.Id == id);
+            toReturn = await db.Customers.FirstOrDefaultAsync(x => x.Id == id);
         }
 
         if (toReturn is not null)
@@ -323,7 +323,7 @@ public class MainDbService : IMainDbService
     {
         using var db = await contextFactory.CreateDbContextAsync();
 
-        var _transaction = db.TransactionRecord.Where(x => x.Id == transactionId //&& x.ChargeBoxId == session.ChargeBoxId
+        var _transaction = db.TransactionRecords.Where(x => x.Id == transactionId //&& x.ChargeBoxId == session.ChargeBoxId
             ).FirstOrDefault();
 
         _transaction.MeterStop = meterStop;
@@ -411,12 +411,12 @@ public class MainDbService : IMainDbService
         using var semaphoreWrapper = await startupSemaphore.GetToken();
         using var db = await contextFactory.CreateDbContextAsync();
 
-        var _machine = await db.Machine.FirstOrDefaultAsync(x => x.ChargeBoxId == chargeBoxId);
+        var _machine = await db.Machines.FirstOrDefaultAsync(x => x.ChargeBoxId == chargeBoxId);
         _machine.ChargeBoxSerialNumber = machine.ChargeBoxSerialNumber;
         _machine.ChargePointSerialNumber = machine.ChargePointSerialNumber;
         _machine.ChargePointModel = machine.ChargePointModel;
         _machine.ChargePointVendor = machine.ChargePointVendor;
-        _machine.FW_CurrentVersion = machine.FW_CurrentVersion;
+        _machine.FwCurrentVersion = machine.FwCurrentVersion;
         _machine.Iccid = DateTime.UtcNow.ToString("yy-MM-dd HH:mm");
         _machine.Imsi = machine.Imsi;
         _machine.MeterSerialNumber = machine.MeterSerialNumber;
@@ -436,12 +436,12 @@ public class MainDbService : IMainDbService
 
         foreach (var pam in pams)
         {
-            var _machine = db.Machine.FirstOrDefault(x => x.ChargeBoxId == pam.ChargeBoxId);
+            var _machine = db.Machines.FirstOrDefault(x => x.ChargeBoxId == pam.ChargeBoxId);
             _machine.ChargeBoxSerialNumber = pam.machine.ChargeBoxSerialNumber;
             _machine.ChargePointSerialNumber = pam.machine.ChargePointSerialNumber;
             _machine.ChargePointModel = pam.machine.ChargePointModel;
             _machine.ChargePointVendor = pam.machine.ChargePointVendor;
-            _machine.FW_CurrentVersion = pam.machine.FW_CurrentVersion;
+            _machine.FwCurrentVersion = pam.machine.FwCurrentVersion;
             _machine.Iccid = DateTime.UtcNow.ToString("yy-MM-dd HH:mm");
             _machine.Imsi = pam.machine.Imsi;
             _machine.MeterSerialNumber = pam.machine.MeterSerialNumber;
@@ -461,7 +461,7 @@ public class MainDbService : IMainDbService
         ConnectorStatus status = new() { Id = Id };
 
         db.ChangeTracker.AutoDetectChangesEnabled = false;
-        db.ConnectorStatus.Attach(status);
+        db.ConnectorStatuses.Attach(status);
 
 
         status.CreatedOn = Status.CreatedOn;
@@ -510,7 +510,7 @@ public class MainDbService : IMainDbService
     private async Task<Guid> GetCustomerIdByChargeBoxIdEF(string chargeboxId)
     {
         using var db = await contextFactory.CreateDbContextAsync();
-        var _CustomerId = await db.Machine.Where(x => x.ChargeBoxId == chargeboxId).Select(x => x.CustomerId).FirstOrDefaultAsync();
+        var _CustomerId = await db.Machines.Where(x => x.ChargeBoxId == chargeboxId).Select(x => x.CustomerId).FirstOrDefaultAsync();
         return _CustomerId;
     }
 
@@ -533,7 +533,7 @@ public class MainDbService : IMainDbService
     private async Task<int?> TryGetDuplicatedTransactionIdEF(string chargeBoxId, Guid customerId, int connectorId, DateTime timestamp)
     {
         using var db = await contextFactory.CreateDbContextAsync();
-        var _existedTx = await db.TransactionRecord.Where(x => x.CustomerId == customerId && x.ChargeBoxId == chargeBoxId
+        var _existedTx = await db.TransactionRecords.Where(x => x.CustomerId == customerId && x.ChargeBoxId == chargeBoxId
                                && x.ConnectorId == connectorId && x.StartTime == timestamp).Select(x => x.Id).FirstOrDefaultAsync();
         return _existedTx;
     }
@@ -563,7 +563,7 @@ public class MainDbService : IMainDbService
     private async ValueTask AddMachineErrorEF(byte connectorId, DateTime createdOn, int status, string chargeBoxId, int errorCodeId, string errorInfo, int preStatus, string vendorErrorCode, string vendorId)
     {
         using var db = await contextFactory.CreateDbContextAsync();
-        await db.MachineError.AddAsync(new MachineError()
+        await db.MachineErrors.AddAsync(new MachineError()
         {
             ConnectorId = connectorId,
             CreatedOn = createdOn,
@@ -612,7 +612,7 @@ public class MainDbService : IMainDbService
             ConnectorStatus status = new() { Id = param.Id };
 
             //db.ChangeTracker.AutoDetectChangesEnabled = false;
-            db.ConnectorStatus.Attach(status);
+            db.ConnectorStatuses.Attach(status);
 
 
             status.CreatedOn = param.Status.CreatedOn;
@@ -678,7 +678,7 @@ public class MainDbService : IMainDbService
 
         foreach (var message in bundleHandlerData.Datas)
         {
-            await db.ServerMessage.AddAsync(message);
+            await db.ServerMessages.AddAsync(message);
         }
 
         await db.SaveChangesAsync();
@@ -693,7 +693,7 @@ public class MainDbService : IMainDbService
         using var db = await contextFactory.CreateDbContextAsync();
         using var trans = await db.Database.BeginTransactionAsync();
 
-        await db.ServerMessage.AddAsync(message);
+        await db.ServerMessages.AddAsync(message);
 
         await db.SaveChangesAsync();
         await trans.CommitAsync();
@@ -730,7 +730,7 @@ public class MainDbService : IMainDbService
     {
         using var db = await contextFactory.CreateDbContextAsync();
 
-        await db.TransactionRecord.AddAsync(newTransaction);
+        await db.TransactionRecords.AddAsync(newTransaction);
 
         await db.SaveChangesAsync();
 
@@ -772,7 +772,7 @@ public class MainDbService : IMainDbService
     private async Task<TransactionRecord> GetTransactionForStopTransactionEF(int transactionId, string chargeBoxId)
     {
         using var db = await contextFactory.CreateDbContextAsync();
-        return await db.TransactionRecord.Where(x => x.Id == transactionId
+        return await db.TransactionRecords.Where(x => x.Id == transactionId
              && x.ChargeBoxId == chargeBoxId).FirstOrDefaultAsync();
     }
 
@@ -908,7 +908,7 @@ public class MainDbService : IMainDbService
                 var machine = new Machine() { Id = data.Id };
                 if (machine != null)
                 {
-                    db.Machine.Attach(machine);
+                    db.Machines.Attach(machine);
                     machine.HeartbeatUpdatedOn = DateTime.UtcNow;
                     machine.ConnectionType = data.ConnectionType;
                     db.Entry(machine).Property(x => x.HeartbeatUpdatedOn).IsModified = true;

+ 1 - 2
EVCB_OCPP.WSServer/Service/OuterBusinessService.cs

@@ -1,5 +1,4 @@
 using EVCB_OCPP.Domain;
-using EVCB_OCPP.Domain.Models.Database;
 using EVCB_OCPP.Packet.Messages.SubTypes;
 using EVCB_OCPP.WSServer.Dto;
 using Microsoft.EntityFrameworkCore;
@@ -275,7 +274,7 @@ namespace EVCB_OCPP.WSServer.Service
             {
                 using (var db = await maindbContextFactory.CreateDbContextAsync())
                 {
-                    var connectorStatuses = await db.ConnectorStatus.Where(x => x.ChargeBoxId == chargeBoxId).
+                    var connectorStatuses = await db.ConnectorStatuses.Where(x => x.ChargeBoxId == chargeBoxId).
                          Select(x => new { x.ConnectorId, x.Status, x.CreatedOn }).ToListAsync();
 
                     var connectorStatus = connectorStatuses.Where(x => x.Status == 2).OrderByDescending(x => x.CreatedOn).FirstOrDefault();

+ 1 - 1
TestTool.RemoteTriggerAPP/MainWindow.xaml.cs

@@ -878,7 +878,7 @@ namespace TestTool.RemoteTriggerAPP
         {
             using (var db = new MainDBContext())
             {
-                db.MachineOperateRecord.Add(new MachineOperateRecord()
+                db.MachineOperateRecords.Add(new MachineOperateRecord()
                 {
                     CreatedOn = DateTime.UtcNow.ToUniversalTime(),
                     ChargeBoxId = uxChargeBoxIdTb.Text,