title: C# Linq to SQL vs Entity Framework .Net Core
body: <p>I decided to start learning something about .Net Core and Entity Framework for Core. Since most of our apps rely heavily on data access, I decided to start with the Entity Framework for .Net Core. After creating a working app, I decided to run the same the same query using Linq to SQL and test the response time. The database was local (running on the same machine). The EF code was created based on the following article… Data Points - Run EF Core on Both .NET Framework and .NET Core
  (<a href="https://msdn.microsoft.com/en-us/magazine/mt742867.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/magazine/mt742867.aspx</a>).</p>
  
  <p>Linq to Sql vs Entity Famework Core – Speed Test</p>
  
  <p>Linq to SQL in .net Library and called from .Net Console App
  Entity Framework Core in a Core Library called same .Net Console App</p>
  
  <p>The query transfers table fields to a DTO object</p>
  
  <p>Records in Table: 1,906,643; Records returned in Query: 78; Linq to SQL: 3 Seconds; Entity Framework Core: 19 Seconds</p>
  
  <p>Similar Query for Both Linq to SQL and EF Core…</p>
  
  <pre><code>public IEnumerable&lt;PackageDataDTO&gt; GetAll(string Building, string Status="All")
  {
      using (var context = new PackageDataEF.PackageDataContext(_options))
      {
          var Lst = from Dbo in context.PackageData
                    where Dbo.BuildingNumber.Equals(Building)
                    &amp;&amp; (Dbo.Status.Equals("All") || Dbo.Status.Equals(Status))
                    select new PackageDataDTO
                    {
                        RecordGuid = Dbo.RecordGuid,
                        //TimeStamp = Dbo.TimeStamp,
                        BuildingNumber = Dbo.BuildingNumber,
                        UnitNumber = Dbo.UnitNumber,
                        TrackingNumber = Dbo.TrackingNumber,
                        Carrier = Dbo.Carrier,
                        PackageType = Dbo.PackageType,
                        PackageLocation = Dbo.PackageLocation,
                        StorageArea = Dbo.StorageArea,
                        DateOfReceiptUTC = Dbo.DateOfReceiptUTC,
                        DateLastChangeUTC = Dbo.DateLastChangeUTC,
                        Status = Dbo.Status,
                        ResidentId = Dbo.ResidentId,
                        NotificationBy = Dbo.NotificationBy,
                        CallSid = Dbo.CallSid,
                        Comments = Dbo.Comments,
                        DeliveredTo = Dbo.DeliveredTo,
                        DeliveredBy = Dbo.DeliveredBy,
                        DeliveryNotes = Dbo.DeliveryNotes,
                        DeliveryConfirmation = Dbo.DeliveryConfirmation,
                        DelayedNotification = Dbo.DelayedNotification,
                        GroupedNotification = Dbo.GroupedNotification,
                        ButtonOnReceipt = Dbo.ButtonOnReceipt,
                    };
          return Lst.ToList();
      }
  }
  </code></pre>
  
  <p>Is there really that much of a speed difference or am I doing something wrong? </p>
  
  <p>Thanks in advance for any guidance.</p>