none
Arithmetic operation resulted in an overflow

    Question

  • Previously used ASP.Net with VS2013 with SQL database connection to REMOTE database - and thought that I'd mastered how to create SQL-based web apps...until I tried the new ASP.Net Core with VS2015. Tried installing VS2015 Pro and followed PluralSight training for creating simple Visual C# project "ASP.NET Core Web Application (.NET Core)" - failed! Tried simple code example from other wbesites - also failed. Tried Microsoft's own example here: https://docs.asp.net/en/latest/data/ef-mvc/intro.html - also failed. The failures seem to occur when creating the initial database.

    Failed error: "Arithmetic operation resulted in an overflow"

    I am using Windows 10 Enrterprise (64 bit) clean install. Other software includes Office 2016 (32 bit) | Visio 2016 (32 bit).
    I have tried uninstalling any reference to "SQL" from the add/remove programs, and re-installed VS2015. Same problem.

    Can anyone shed light on this problem? It's inhibiting me from learning how to develop the most basic of we apps!

    Every "EF" project sample I try gives the same error: "Arithmetic operation resulted in an overflow". In the case of the above Micrsoft sample, I got as far as section "Create a controller and views", but when I click "Add" (to add a new scaffolded item) I get the following exception (image attached): [trace posted below]

    C:\Program Files\dotnet\dotnet.exe aspnet-codegenerator --project "C:\Users\VirgilTurner\documents\visual studio 2015\Projects\ContosoUniversity\src\ContosoUniversity" controller --force --controllerName StudentsController --model ContosoUniversity.Models.Student --dataContext ContosoUniversity.Data.SchoolContext --relativeFolderPath Controllers --controllerNamespace ContosoUniversity.Controllers --referenceScriptLibraries --useDefaultLayout
    Finding the generator 'controller'...
    Running the generator 'controller'...
    Attempting to compile the application in memory
    Attempting to figure out the EntityFramework metadata for the model and DbContext: Student
    Exception has been thrown by the target of an invocation. StackTrace:
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
       at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
       at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
       at Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.EntityFrameworkServices.TryCreateContextUsingAppCode(Type dbContextType, ModelType startupType)
    Arithmetic operation resulted in an overflow. StackTrace:
       at System.Data.SqlClient.SNINativeMethodWrapper.SNIOpenSyncExWrapper(SNI_CLIENT_CONSUMER_INFO& pClientConsumerInfo, IntPtr& ppConn)
       at System.Data.SqlClient.SNINativeMethodWrapper.SNIOpenSyncEx(ConsumerInfo consumerInfo, String constring, IntPtr& pConn, Byte[] spnBuffer, Byte[] instanceName, Boolean fOverrideCache, Boolean fSync, Int32 timeout, Boolean fParallel)
       at System.Data.SqlClient.SNIHandle..ctor(ConsumerInfo myInfo, String serverName, Byte[] spnBuffer, Boolean ignoreSniOpenTimeout, Int32 timeout, Byte[]& instanceName, Boolean flushCache, Boolean fSync, Boolean fParallel)
       at System.Data.SqlClient.TdsParserStateObject.CreatePhysicalSNIHandle(String serverName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[] spnBuffer, Boolean flushCache, Boolean async, Boolean fParallel)
       at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, TimeoutTimer timeout)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       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.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
       at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerDatabaseCreator.Create()
       at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreated()
       at ContosoUniversity.Models.DbInitializer.Initialize(SchoolContext context)
       at ContosoUniversity.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, SchoolContext context)
    There was an error creating the DbContext instance to get the model. No parameterless constructor defined for this object.
    No parameterless constructor defined for this object.
       at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
       at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
       at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
    RunTime 00:00:22.49


    • Edited by Virgil Turner Wednesday, November 02, 2016 1:12 PM Ambiguous initial sentence
    Wednesday, November 02, 2016 1:10 PM

All replies

  • Hi Virgil Turner,

    >>Tried installing VS2015 Pro and followed PluralSight training for creating simple Visual C# project "ASP.NET Core Web Application (.NET Core)" - failed!

    According to your description, you could not create new ASP.NET Core Web Application (.NET Core) project in VS2015. Please refer to the following steps to troubleshoot this issue:

    1). Please update the ASP.NET Tools for web in VS, click the Tools menu->Extensions and Updates-> Updates->click Visual Studio Gallery-> update the Microsoft ASP.NET and Web Tool option.

    2). Based on step1, update you VS to the latest version (VS2105 Update3 version 14.0.25431.01), update the option beginning with KB letters in Update list box.

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 03, 2016 9:19 AM
    Moderator
  • Hi Virgil Turner,

    Since this issue occurs when creating the initial database and according to the error message, the issue occurs on create DBContext, I suggest you check whether you have installed SQL Server Data Tools for your Visual Studio first. You could check it from Control Panel -> Programs and Features -> Visual Studio 2015 -> Change -> Modify.

    If the SSDT has installed but there still has issues on creating the initial database, I suggest you repair your Visual Studio to check whether there has any installation issues.

    If any progression for this issue, please feel free to come back.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 14, 2016 7:05 AM
    Moderator