Hello
We have issues with connecting to our ABP solution from Android phones. When calling API endpoints to transfer some data. There is an issue with inserting data to DeviceInfo column in AbpSessions table. Volo.Abp verison is 9.3.4
On some phones Session error is thrown:
2025-10-02 08:36:49.198 +02:00 [ERR] Failed executing DbCommand (1ms) [Parameters=[@p0='dea2e24b-bda8-9b0d-94d6-3a1cb5d018a9', @p1='eMRFusion2_Android' (Size = 64), @p2='OAuth' (Nullable = false) (Size = 64), @p3='Dalvik/2.1.0 (Linux; U; Android 15; SM-A546B Build/AP3A.240905.015.A2)' (Size = 4000), @p4='{}' (Size = 4000), @p5='188.198.52.155' (Size = 2048), @p6=NULL (DbType = DateTime2), @p7='98153417-1056-48e0-a934-db9f897c335d' (Nullable = false) (Size = 128), @p8='2025-10-02T08:36:49.1936171+02:00', @p9='36176b5b-ffb3-344c-d988-3a0de86e8481' (Nullable = true), @p10='3569993e-0521-5c8b-8420-3a16f6359437'], CommandType='"Text"', CommandTimeout='0']
SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
INSERT INTO [AbpSessions] ([Id], [ClientId], [Device], [DeviceInfo], [ExtraProperties], [IpAddresses], [LastAccessed], [SessionId], [SignedIn], [TenantId], [UserId])
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10);
2025-10-02 08:36:49.199 +02:00 [ERR] An exception occurred in the database while saving changes for context type 'Infotim.eMRFusion2.EntityFrameworkCore.eMRFusion2DbContext'.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated in table 'eMRFusion2_KranjTEST.dbo.AbpSessions', column 'DeviceInfo'. Truncated value: 'Dalvik/2.1.0 (Linux; U; Android 15; SM-A546B Build/AP3A.240905.0'.
The statement has been terminated.
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
ClientConnectionId:781cfc2f-801d-4d98-81ae-b18e3ba0c4db
Error Number:2628,State:1,Class:16
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Update.Internal.SqlServerModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChangesAsync(IList`1 entries, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated in table 'eMRFusion2_KranjTEST.dbo.AbpSessions', column 'DeviceInfo'. Truncated value: 'Dalvik/2.1.0 (Linux; U; Android 15; SM-A546B Build/AP3A.240905.0'.
The statement has been terminated.
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
ClientConnectionId:781cfc2f-801d-4d98-81ae-b18e3ba0c4db
Error Number:2628,State:1,Class:16
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Update.Internal.SqlServerModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChangesAsync(IList`1 entries, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Volo.Abp.Uow.UnitOfWork.SaveChangesAsync(CancellationToken cancellationToken)
at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
5 Answer(s)
-
0
The error you are encountering is due to the DeviceInfo column in your AbpSessions table being defined as nvarchar(64), which is too short to store the full device information string sent by some Android devices. The error message:
String or binary data would be truncated in table 'eMRFusion2_KranjTEST.dbo.AbpSessions', column 'DeviceInfo'. Truncated value: 'Dalvik/2.1.0 (Linux; U; Android 15; SM-A546B Build/AP3A.240905.0'
indicates that the value being inserted exceeds the 64-character limit.
Solution
You need to increase the length of the DeviceInfo column in your AbpSessions table. For example, you can change it from nvarchar(64) to nvarchar(4000):
ALTER TABLE [AbpSessions] ALTER COLUMN [DeviceInfo] NVARCHAR(4000) NULL;
After updating the column size, you should also update your Entity Framework Core model if you have any explicit configuration for this property.
Steps:
- Update the database column as shown above.
- If you have an EntityTypeConfiguration or model definition for AbpSession, update the DeviceInfo property to match the new length.
- Regenerate and apply any necessary EF Core migrations if you are using code-first migrations.
This will allow longer device info strings to be stored without causing truncation errors.
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
We are not able to increase the column size in AbpSessions, because it is part of ABP solution.
-
0
hi
You can
- Change the
IdentitySessionConsts.MaxDeviceInfoLength
and add a new EF Core migration to increase the length of the session entity.
public class IdentitySessionConsts { public static int MaxSessionIdLength { get; set; } = 128; public static int MaxDeviceLength { get; set; } = 64; public static int MaxDeviceInfoLength { get; set; } = 64; public static int MaxClientIdLength { get; set; } = 64; public static int MaxIpAddressesLength { get; set; } = 2048; }
- Replace the built-in
IWebClientInfoProvider
service.
using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using MyCSharp.HttpUserAgentParser.Providers; using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.WebClientInfo; [Dependency(ReplaceServices = true)] [ExposeServices(typeof(HttpContextWebClientInfoProvider), typeof(IWebClientInfoProvider))] public class MyHttpContextWebClientInfoProvider : HttpContextWebClientInfoProvider { public MyHttpContextWebClientInfoProvider( ILogger<HttpContextWebClientInfoProvider> logger, IHttpContextAccessor httpContextAccessor, IHttpUserAgentParserProvider httpUserAgentParser) : base(logger, httpContextAccessor, httpUserAgentParser) { } protected override string? GetDeviceInfo() { var info = base.GetDeviceInfo(); return info?.Substring(0, 64); } }
- Change the
-
0
Second solution works.Thank you.
-
0
Thanks, we also will increase the length in abp 10.0