A strange phenomenon of the EF 6.0 while inserting data? RRS feed

  • Question

  • User-252718598 posted


    1. EF 6.0 used

    2. Code first used.


    I use code first to insert a data to the DB, no any exception throws(I make sure). then I select the data inserted just before, but no data shows in DB(select * from XXX)。

    then I use  sql profiler to monitor the sql which created by EF, Curiously, the sql catched, but no data was inserted successfully.

    PS: But It's ok while executing the sql catched manually.Frown

    the sql I  cathched as below:

    exec sp_executesql N'INSERT [dbo].[T_TempBookChapter]([bookID], [fileName], [chapterName], [source], [thirdChapterID], [charNum], [status], [orderID], [hasSensitiveKey], [avgPrice], [price], [isPushed], [isBought], [isSynchroToOnline], [expectedPusheDate], [CreateTime], [UpdateTime], [CancelTime])
    VALUES (@0, @1, @2, @3, NULL, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, NULL, NULL)
    FROM [dbo].[T_TempBookChapter]
    WHERE @@ROWCOUNT > 0 AND [ID] = scope_identity()',N'@0 int,@1 nvarchar(max) ,@2 nvarchar(max) ,@3 nvarchar(max) ,@4 int,@5 int,@6 int,@7 int,@8 decimal(18,2),@9 decimal(18,2),@10 bit,@11 bit,@12 bit,@13 datetime2(7),@14 datetime2(7)',@0=1046265,@1=N'1046265_201606021635290777_3139_1.txt',@2=N'正文 第446章 从此,不再做软弱的尹月溪!',@3=N'海外Q阅读',@4=2123,@5=1,@6=1,@7=0,@8=0,@9=0,@10=0,@11=1,@12=0,@13='1900-01-01 00:00:00',@14='2016-06-02 16:35:29.0537696'

    who can tell me why?Frown thanks for you in advanced!!!

    Thursday, June 2, 2016 9:24 AM


  • User753101303 posted


    You don't find the data even when stepping throught the code right after the insert? Could it be that EF is configured to always drop/recreate the db, or if using AttachDBFileName that the file is overwritten or that you don't check another file than this one ?

    For example does the line you get when running this SQL statement disappear as well later in your app or it is then  seen forever?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 2, 2016 9:40 AM