Entity framework doesn't update the bit value

entity-framework entity-framework-6

Accepted Answer

I was utilising the [DatabaseGenerated(DatabaseGeneratedOption.Computed)] property to create values by default, however this prevented the Entity Framework from producing the SQL necessary to update the entries. As a result, when I removed this attribute, the EF produced the necessary updating items. I could now continue working. but this kind of code is correct or incorrect... Can any experienced folks provide me advice on how to fix these kinds of issues?

Regards BosH

2
10/18/2016 7:34:49 AM

Popular Answer

There is no need to utilise the as the object is loaded and monitored.Entry Simply alter the value of the property and save the entity.

using (var context = new TriviaContext())
            {

                var booking = context.Booking.Find(id);
                booking.IsActive = false;
                context.SaveChanges();

                return Ok(booking);
            }


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow