I try to update a record of my bd with entity framework but it does not update it (It does not mark errors)

0

What I want to do is a simple update of a record of my table and in this case I want to do it with linq but at the moment when it arrives at that piece of code it does not mark me any mistake and executes all the lines but it does not I update the record:

Update current code:

   clasexxx vehiculo = (from conf in context.xxx
                                           where conf.xxx.Equals(config.xxx)
                                           select new clasexxx()
                                           {
                                               xxx = conf.xxx,
                                           }).First();
               vehiculo.Idioma = config.Idioma;
                context.SaveChanges();
                return retorno;

I can now make insertions of my registration but I want that when the school id does not come back to add but simply update the one that already exists.

    
asked by David 27.06.2018 в 20:50
source

2 answers

1

For an edition use this route.

 context.Entry(vehiculo).State = EntityState.Modified;
 context.SaveChanges();
    
answered by 27.06.2018 в 21:00
0

I think the problem is in obtaining data with the new

Try this:

clasexxx vehiculo = context.xxx.where(conf => conf.xxx.Equals(config.xxx)).FirstOrDefault();

               vehiculo.Idioma = config.Idioma;
                context.SaveChanges();
                return retorno;
    
answered by 02.07.2018 в 12:48