Roman
Roman

Reputation: 523

EF 6 Arithmetic Overflow on Open

I am trying to solve a boring issue with an EF 6 data context now for several hours, though the entire code is small and simple. I did the same within the same solution already a couple of times and I never encountered this problem. Even when I compare the different implementations, configurations and references, I cannot find a difference. Here is the (very small) code snippet:

using (var context = new ConnectorDataContext())
{
    var customer = context.Customers.FirstOrDefault();
}

Of course, there is more inside the using after the query, but it is not relevant whether it is there or not. The collection is defined as

DbSet<ConnectCustomer> Customer {get;set;}

The context is derived from DbContext. Everything is attributed correctly (was copied from other, well working code parts of the solution.

The connection string points to a database which is used in other parts of the solution too. Yet, the test is isolated, so there is definately no other open connection.

But now, with this one, I always get an EntityException, caused by the underlying Provider, with an inner exception of "Overflow caused by the arithmetic operation". I am really close to desperation. Please help.

Upvotes: 1

Views: 889

Answers (2)

Nikola
Nikola

Reputation: 1

I had the same issue. The application worked fine and then it suddenly started with the exceptions (no apparent changes in the code were made).

The solution was uninstalling program called "Web Companion" (I accidentally installed it by installing something else and not unticking during the installation process).

Therefore if you suddenly get these errors for no apparent reason, check for recent programs installed on your machine. Some of them can apparently cause it.

Upvotes: 0

wazdev
wazdev

Reputation: 353

I've been battling a similar issue for far too long, and have only seen it emerge since upgrading to EF 6.x (not that I can conclusively say this is the cause). In my case, all calls to entity framework extension methods result in the "Arithmetic Overflow on Open" exception. Additionally, I only see this issue with IIS (any version), not IIS Express.

I found the following combination of things fixed the issue for me:

  1. Manually clean your deployment location (del your obj and bin folders), try creating a new DB and point to it instead

  2. Ensure your App Pool in IIS has "Enable 32-Bit Applications" set to True (right click on App Pool -> Advanced Settings)

  3. Ensure that your database accepts remote connections - SQL Server Mgmt Studio, Right click on DB Server Instance -> Properties -> Connections -> Check the "Allow remote connections to this server" box

  4. Ensure that DTC allows "Remote Clients": Windows Search for "Component Services" -> expand Computers -> My Computer -> Distributed Transaction Coordinator -> Right Click on "Local DTC" -> properties -> Security Tab -> Check Network DTC Access, Allow Remote Clients, Allow Inbound and Allow Outbound Transaction Manager Communication

  5. Ensure that your Connection String is legit. I find this useful: http://www.developerfusion.com/tools/sql-connection-string/

Best of luck

Upvotes: 1

Related Questions