Entity Framework 4: poor performance with SQL Server 2008

I am developing software based on the Entity Framework for processing data in an MS SQL Server 2008 database.

[Problem 1]

I just tried to insert some small data ( about 2 MB ) from my program into the database: performance is very poor! It takes more than 1 minute to insert this data !

I am trying to generate precompiled views, I have the same results: - (

My code uses a business layer (automatically created from a .edmx file with a T4 template) to manage data at the service level. It is very important to navigate in the relationship of objects.

How to improve the performance of these inserts using the Entity Framework?

[Problem 2]

In addition, before inserting data into the database using the SaveChanges () method, I fill out my object context using the AddObject () method. I add about 100,000 small objects (about 2 MB) to the object context using AddObject (): it takes a very long time (more than 10 minutes)!

How can I reduce this time?

UPDATE

Should my program store more than 50 MB in a database in less than 2-3 minutes? Do you think this is possible with EF?

+3
source share
8 answers

Entity Framework Profiler, , SQL . 30- . , " Entity Framework".

EF

Edit

, EF . , . , - 10 6 .

+4

.

  • 100 000 . ? , , ? ?

  • - . ? -? / - ?

, , , . , , .

-, SQL Profiler . , , .

, , .

UPDATE
EF 100 000 , ( ). , ORM .

2
, , . , 4 . : , SQL Server, , , . SQL Server - . (FYI - SQL )

- SQL-, , , , , .

+2

EF ( LINQ2SQL, ) / . /. , . , , EF SP , EDMX. Google EF.

+2

SQL Server Profiler, .

+1

, Entity Framework, , , . .

SQL, Entity Framework, ObjectQuery.ToTraceString.

SQL, Entity Framework, , , .

+1

, 100 000 , SaveChanges. , SaveChanges Entity Framework. , , 100 , SaveChanges . , , . , , , .

, , . poco, , , , IEntityWithChangeTracking ( EntityObject, ).

+1

, Entity Framework , , , .

, - 1 .

, SqlBulkCopy Entity Framework.

Entity Framework SqlBulkCopy : SQL Server

+1

. SQL Profiler . , Entity Framework SQL INSERT UPDATE , .

I'm not sure if this has anything to do with this problem, but I would run SQL Profiler and analyze the results. I could also track your disk usage (read and write) on your SQL box (if possible) and see if there are any red flags.

0
source

Source: https://habr.com/ru/post/1768620/


All Articles