Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using AddOrUpdate from System.Data.Entity.Migrations
Message
De
08/04/2014 17:28:31
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01598293
Message ID:
01598317
Vues:
30
>>We're having a debate about whether to use EF AddOrUpdate.
>>
>>According to Julie Lerman at http://thedatafarm.com/data-access/take-care-with-ef-4-3-addorupdate-method/ you should only use AddOrUpdate when doing Data Migrations during development.
>>
>>My co-workers are saying that using AddOrUpdate is acceptable even though it makes a round trip query to the database to see if the record exists in order to determine whether it creates an update or an insert command. I've seen that in SQL Profiler.
>>
>>And Julie makes other arguments against its use as well.
>>
>>Thanks.
>
>The generated SQL code at the bottom of the blog post is quite strange.
>
>BTW, for SQL 2008 and up the update or insert should be done with MERGE and in this case this method will be OK.

To be fair, most of the SQL generated from EF is strange.
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform