none
Entity framework doesn't update the bit value RRS feed

  • Question

  • Hi everyone,

    I have a strange problem with entity framework, In my project im using EF 6 codefirst and for my database im using sqlserver 2012

    as with a table iam using isactive column of type bit, which represents 0 or 1 only. and defaultly i kept this column value as 1 which is represents true.

    When we want to delete a record from the table we should have to make 1 to 0, but the entity framework doesn't updating the value.

    is any one having this strange problem any 1 with solution here ??

    Regards 

    BosH

    • Moved by Kristin Xie Monday, October 17, 2016 8:49 AM EF related
    Monday, October 17, 2016 5:11 AM

All replies

  • May be post your code here with help the people here to help you.

    You can update the EF from Database and see it is still happening.

    You actually can post your question here:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework&filter=alltypes&sort=lastpostdesc

    chanmm


    chanmm

    Monday, October 17, 2016 5:30 AM
  • Hi,

    According to your description, I create a simple demo as below, it works well, Could you please provide a bit more information about your issue, such as related code, Data table structure, related error message.

    #DataTable

    CREATE TABLE [dbo].[Dogs] (
        [Id]        INT           IDENTITY (1, 1) NOT NULL,
        [Name]      NVARCHAR (50) NULL,
        [IsDeleted] BIT           NULL
    );
    
    

    #Usage:

     using (var db = new Model1())
                {
                    var dog = db.Dogs.Find(1);
    
                    dog.IsDeleted = false;
    
                    db.SaveChanges();
                }

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 18, 2016 3:01 AM
    Moderator