EF core 3.1 Divide by zero error encountered with no division performed

-1

I am trying to migrate a .net core 2.2 project to 3.1. So far I have encounter many issues, the first one was the classic Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException because I am manually assigning the Ids instead of auto-generating them with EF.

So I corrected that with the fluent API (ValueGeneratedNever()) and annotations ([DatabaseGenerated(DatabaseGeneratedOption.None)]). I'm not sure why I needed to do both, but EF wouldn't shut up about it until I did the annotations as well.

So, now my problem is that after that was sorted, the next error was System.Data.SqlClient.SqlException (0x80131904): Divide by zero error encountered. However, and here is the kicker, I am not performing ANY divisions at all. I'm simply saving to the DB some entity and its children. More specifically what I'm doing is to safe information from YouTube videos, so the parent would be the video and the children would be stats, freebaserdf, keywords and wikitopics.

The error happens after inserting WikiTopics as you can see in the log, but I also realized that the insert of the video failed also no idea why. I haven't change the code other than to add the annotations and fluent API I mentioned before.

INSERT INTO [Video] ([YTVideoId], [Caption], [CategoryId], [DefaultAudioLanguage], [Description], [Dimension], [Duration], [Engagement], [LicensedContent], [LiveBroadcastContent], [PublishedAt], [Reach], [RegisterTime], [Title], [YTchannelId])
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14);
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.7\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Microsoft.EntityFrameworkCore.Database.Command:Error: Failed executing DbCommand (39ms) [Parameters=[@p15='?' (DbType = Guid), @p16='?' (Size = 4000), @p17='?' (Size = 450), @p18='?' (DbType = Guid), @p19='?' (Size = 4000), @p20='?' (Size = 450), @p21='?' (DbType = Guid), @p22='?' (Size = 4000), @p23='?' (Size = 450), @p24='?' (DbType = Guid), @p25='?' (DbType = Decimal), @p26='?' (DbType = Decimal), @p27='?', @p28='?' (DbType = Decimal), @p29='?' (DbType = Decimal), @p30='?', @p31='?' (DbType = Decimal), @p32='?' (Size = 450), @p33='?' (DbType = Guid), @p34='?' (Size = 4000), @p35='?' (Size = 450), @p36='?' (DbType = Guid), @p37='?' (Size = 4000), @p38='?' (Size = 450), @p39='?' (DbType = Guid), @p40='?' (Size = 4000), @p41='?' (Size = 450), @p42='?' (DbType = Guid), @p43='?' (Size = 4000), @p44='?' (Size = 450), @p45='?' (DbType = Guid), @p46='?' (Size = 4000), @p47='?' (Size = 450), @p48='?' (DbType = Guid), @p49='?' (Size = 4000), @p50='?' (Size = 450), @p51='?' (DbType = Guid), @p52='?' (Size = 4000), @p53='?' (Size = 450), @p54='?' (DbType = Guid), @p55='?' (Size = 4000), @p56='?' (Size = 450), @p57='?' (DbType = Guid), @p58='?' (Size = 4000), @p59='?' (Size = 450), @p60='?' (DbType = Guid), @p61='?' (Size = 4000), @p62='?' (Size = 450), @p63='?' (DbType = Guid), @p64='?' (Size = 4000), @p65='?' (Size = 450), @p66='?' (DbType = Guid), @p67='?' (Size = 4000), @p68='?' (Size = 450), @p69='?' (DbType = Guid), @p70='?' (Size = 4000), @p71='?' (Size = 450), @p72='?' (DbType = Guid), @p73='?' (Size = 4000), @p74='?' (Size = 450), @p75='?' (DbType = Guid), @p76='?' (Size = 4000), @p77='?' (Size = 450)], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
INSERT INTO [VideoFreeBaseRdf] ([Id], [TopicId], [YTVideoId])
VALUES (@p15, @p16, @p17),
(@p18, @p19, @p20),
(@p21, @p22, @p23);
INSERT INTO [VideoStat] ([Id], [CommentCount], [DislikeCount], [Engagement], [FavoriteCount], [LikeCount], [Reach], [ViewCount], [YTVideoId])
VALUES (@p24, @p25, @p26, @p27, @p28, @p29, @p30, @p31, @p32);
SELECT [RegisteredTime]
FROM [VideoStat]
WHERE @@ROWCOUNT = 1 AND [Id] = @p24;

INSERT INTO [VideoTag] ([Id], [TagValue], [YTVideoId])
VALUES (@p33, @p34, @p35),
(@p36, @p37, @p38),
(@p39, @p40, @p41),
(@p42, @p43, @p44),
(@p45, @p46, @p47),
(@p48, @p49, @p50),
(@p51, @p52, @p53),
(@p54, @p55, @p56),
(@p57, @p58, @p59),
(@p60, @p61, @p62),
(@p63, @p64, @p65),
(@p66, @p67, @p68),
(@p69, @p70, @p71);
INSERT INTO [VideoWikiTopics] ([Id], [TopicCategory], [YTVideoId])
VALUES (@p72, @p73, @p74),
(@p75, @p76, @p77);

System.Data.SqlClient.SqlException (0x80131904): Divide by zero error encountered.
The statement has been terminated.
   at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__126_0(Task`1 result)
   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 where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
ClientConnectionId:cc9a1718-fbdb-4874-9007-8576818c1d91

Any ideas?

c#
sql-server
.net-core
ef-core-3.1
asked on Stack Overflow Mar 4, 2020 by gris

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0