barcelona
barcelona

Reputation: 11

WCF insert into DB using EF

I have created a WCF service with below operation to insert into DB. (Pseudo code)

    // Context mode is percall
    AddUser
   {
        var dbCtx = new MyEntity();
        dbCtx.DbSet.Add(Record);
        dbCtx.SaveChanges();
    }

This method is called many times by the client asynchronously. How to improve its performance? How to perform group insert and call savechanges across multiple calls.

Upvotes: 1

Views: 26

Answers (1)

Abhinav Galodha
Abhinav Galodha

Reputation: 9928

For performance improvement, Firstly, you need to benchmark your method calls. for e.g. what time is it taking for the method if it is called by 'n' users.

As one of the option you may use Visual Studio Instrumentation profiler (https://msdn.microsoft.com/en-us/library/dd264994.aspx) to know the HotPath and then work on Performance Improvement.

Also, on the wcf side, you can definitely make some improvements and refer to links 1. https://msdn.microsoft.com/en-us/library/vstudio/Hh273113%28v=VS.100%29.aspx 2. Performance Tuning WCF Service

For EF, you can make optimizations like precompiled queries etc. More details at link https://msdn.microsoft.com/en-us/data/hh949853.aspx

Upvotes: 1

Related Questions