New Posts New Posts RSS Feed: Slow Saves
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Slow Saves

 Post Reply Post Reply
Author
mbevins1 View Drop Down
Newbie
Newbie


Joined: 16-Jan-2009
Posts: 27
Post Options Post Options   Quote mbevins1 Quote  Post ReplyReply Direct Link To This Post Topic: Slow Saves
    Posted: 21-Sep-2009 at 6:48am

When ever we save anything, the very first time we call entityManager.SaveChanges, it take a long time. After checking out the log files, I notices these two entries.

Unable to locate an implementation of: IdeaBlade.EntityModel.Server.IEntityServerSaving
Unable to locate an implementation of: IdeaBlade.EntityModel.Server.IEntityServerSaved

Could this be why it is taking  long time to save?  Also, how do you implement these because I added them to my save class and I still received these messages?

Here is what I added:

Added IEntityServerSaving, IEntityServerSaved to my Save Class


public class SavingService : EntityBaseService, IEntityServerSaving, IEntityServerSaved

Then added these 2 methods

public void OnSaving(EntityServerSavingEventArgs e)

{

if (!e.Principal.Identity.IsAuthenticated)

{

e.Cancel = true;

}

}

public void OnSaved(EntityServerSavedEventArgs e)

{
}
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 21-Sep-2009 at 12:59pm
In addition to implementing the interfaces, you must list the assembly where they reside in the list of top-level (not edmKey) probe assemblies in the app.config file.

Re the performance issues:

There is a performance hit the first time DevForce engages the Entity Framework; both EF and DevForce need to set up their metadata.  There should not be any appreciable performance hit associated with probing for the IEntityServiceSaving and IEntityServiceSaved classes, whether or not they're found. But we'll check into it.

Back to Top
mbevins1 View Drop Down
Newbie
Newbie


Joined: 16-Jan-2009
Posts: 27
Post Options Post Options   Quote mbevins1 Quote  Post ReplyReply Direct Link To This Post Posted: 22-Sep-2009 at 4:16am
I added it to the app.config file and we are no longer getting the error. 
 
So, in addition to the first time devforce starts up and you log in, the very first time you save you will see this delay? The reason this is an issue is due to it takeing over 10 seconds the first time and then everytime after that it is fine.
 
 
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 22-Sep-2009 at 10:03am
It's not the first time you save: it's the first time you hit the Entity Framework. Could also be a data retrieval.
Back to Top
mbevins1 View Drop Down
Newbie
Newbie


Joined: 16-Jan-2009
Posts: 27
Post Options Post Options   Quote mbevins1 Quote  Post ReplyReply Direct Link To This Post Posted: 22-Sep-2009 at 10:10am
This is actually when we save too, at the time we are saving we have already hit the framework and have retrieved some data.
Back to Top
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Posted: 23-Sep-2009 at 12:59pm
We are experiencing this exact behavior too. The first save with the entity manager takes 5-10 seconds to complete. To echo mbevins1, why is this still happening after we've retrieved data from the framework? GregD, is there a trick to initializing the EF during application load so that the user can expect the delay as a normal part of application start-up?
puctx
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 23-Sep-2009 at 7:36pm
We have long thought that the only performance hit was in the first time the EF metadata was loaded as EF performed view generation.  Based on testing today with a customer's database where the hit was 20-30 seconds for both the first query AND the first save, we now think otherwise. 
 
The workaround is to use pre-generated views, which you can read about here - http://msdn.microsoft.com/en-us/library/bb896240.aspx.  This is actually pretty easy to set up, and can improve performance dramatically for both the first query and the first save performed.
 
We'll be investigating further why the double hit is occurring and what we can do to mitigate it.
 
Back to Top
skingaby View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 23-Apr-2008
Location: United States
Posts: 146
Post Options Post Options   Quote skingaby Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2009 at 8:36am
There is a wrinkle when pre-generating views for Entity Model projects with embedded metadata. (And it is definitely easier to work with embedded metadata in and Ideablade solution.) I posted an explanation here: Pre-Generating Entity Framework Views with Embedded Metadata
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down