When I use the DbSet.Find(myEntity.Id) method, a select expression which is 215 KB in size is generated and sent to the server.
It takes the Find method > 3 seconds to generate the select expression string.
I see a *lot* of sub-selects, unions and case expressions… over 8 tables.
Any clues what might be happening here?
– I have a base class which defines a Guid “Id” property annotated with [Key]
– Several classes derive from this class
– The store is created nicely for me; every table has an “Id” field which is the primary key
The following is generated for just 1 abstract base class with two derived classes. Note that in my real scenario this select statement becomes 250 times bigger.
When not using the KeyAttribute but instead using the fluent API for definition of keys, then – for the minimal example above – the select statement becomes much more straightforward.So does this mean: use [Key] if you want to get into trouble – and vice versa?exec sp_executesql N’SELECT
Well, after removing all my [Key] attributes and defining them via the fluent API instead, my application became a