Reputation: 1921
I tried Entity Framework 6.0.2 Code First from NuGet. There is one row in db, condition is just simple as this (EF generated sql):
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Name] AS [Name],
[Extent1].[Practised] AS [Practised],
[Extent1].[SourceLangId] AS [SourceLangId],
[Extent1].[TargetLangId] AS [TargetLangId],
[Extent1].[UserId] AS [UserId]
FROM [dbo].[Dictionary] AS [Extent1]
WHERE ([Extent1].[UserId] = @p__linq__0) AND (@p__linq__0 IS NOT NULL)
I call the EF like this:
IEnumerable<Dictionary> dics = context.Dictionaries.Where(s => s.UserId == userId);
The query execution time is about 15 - 16 sec.! When I call exactly same sql directly with ADO, the query execution time is 0,0010017 sec.
I'm not sure if the time is caused by sql execution, or getting data from SQL to Entity.
Thank you
EDIT:
Dictionary is the Code First entity:
public class Dictionary
{
[Key]
[ScaffoldColumn(false)]
public long Id { get; set; }
[Display(Name = "Name")]
[Required]
[MaxLength(25)]
public string Name { get; set; }
public int Practised { get; set; }
public long SourceLangId { get; set; }
public virtual Lang SourceLang { get; set; }
public long TargetLangId { get; set; }
public virtual Lang TargetLang { get; set; }
public long UserId { get; set; }
public virtual User User { get; set; }
}
Upvotes: 0
Views: 963