Improving bulk insert performance in Entity framework [duplicate]

There is opportunity for several improvements (if you are using DbContext): Set: yourContext.Configuration.AutoDetectChangesEnabled = false; yourContext.Configuration.ValidateOnSaveEnabled = false; Do SaveChanges() in packages of 100 inserts… or you can try with packages of 1000 items and see the changes in performance. Since during all this inserts, the context is the same and it is getting bigger, … Read more

Linq to EntityFramework DateTime

When using LINQ to Entity Framework, your predicates inside the Where clause get translated to SQL. You’re getting that error because there is no translation to SQL for DateTime.Add() which makes sense. A quick work-around would be to read the results of the first Where statement into memory and then use LINQ to Objects to … Read more

Linq Syntax – Selecting multiple columns

As the other answers have indicated, you need to use an anonymous type. As far as syntax is concerned, I personally far prefer method chaining. The method chaining equivalent would be:- var employee = _db.EMPLOYEEs .Where(x => x.EMAIL == givenInfo || x.USER_NAME == givenInfo) .Select(x => new { x.EMAIL, x.ID }); AFAIK, the declarative LINQ … Read more

Using SQL Server 2008 and SQL Server 2005 and date time

A quick google points me to what looks like the solution. Open your EDMX in a file editor (or “open with…” in Visual Studio and select XML Editor). At the top you will find the storage model and it has an attribute ProviderManifestToken. This has should have the value 2008. Change that to 2005, recompile … Read more

Entity Framework Refresh context? [closed]

The best way to refresh entities in your context is to dispose your context and create a new one. If you really need to refresh some entity and you are using Code First approach with DbContext class, you can use public static void ReloadEntity<TEntity>( this DbContext context, TEntity entity) where TEntity : class { context.Entry(entity).Reload(); … Read more

How to “warm-up” Entity Framework? When does it get “cold”?

What would be the best approach to have high availability on my Entity Framework at anytime? You can go for a mix of pregenerated views and static compiled queries. Static CompiledQuerys are good because they’re quick and easy to write and help increase performance. However with EF5 it isn’t necessary to compile all your queries … Read more

what is difference between a Model and an Entity

The definition of these terms is quite ambiguous. You will find different definitions at different places. Entity: An entity represents a single instance of your domain object saved into the database as a record. It has some attributes that we represent as columns in our tables. Model: A model typically represents a real world object … Read more