0

I am facing following error while calling simple GET method of my controller:

**Message**: 
Arithmetic operation resulted in an overflow.
**StackTrace**: 
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open()
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer)
at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func`2 operation, Func`2 verifySucceeded, TState state)
at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__15`2.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()

And my GET method is as follows:

[HttpGet]
public IEnumerable<Categories> GetCategories()
{
   var data = _context.Categories;
   return data;
}

So please let me know how to resolve the issue?

Thanks,

Kunal Kakkad

Kunal Kakkad
  • 653
  • 6
  • 19
  • 2
    Have you searched for "TryGetConnection Arithmetic overflow"? I found this [SO Question](https://stackoverflow.com/questions/32609088/arithmetic-overflow-exception-when-opening-sql-connection) and this [Other SO Question](https://stackoverflow.com/questions/25836198/cant-open-sqlconnection-within-nunit-test) and this [Github Discussion](https://github.com/dotnet/corefx/issues/14288). What have you tried? – Forty3 Oct 30 '17 at 16:34
  • 2
    Please, Can you show your definition for Categories entity and mapping? – H. Herzl Oct 31 '17 at 05:37
  • @Forty3: I had checked all these. But none of them worked. – Kunal Kakkad Oct 31 '17 at 13:55
  • @H.Herzl: modelBuilder.Entity(entity => { entity.HasKey(e => e.CategoryId) .HasName("PK_Categories"); entity.Property(e => e.CategoryDescription).HasMaxLength(500); entity.Property(e => e.CategoryName) .IsRequired() .HasMaxLength(100); entity.Property(e => e.CreatedDate).HasColumnType("datetime"); }); – Kunal Kakkad Oct 31 '17 at 13:55
  • Please edit your question, add the mapping and entity definition – H. Herzl Nov 03 '17 at 03:15

0 Answers0