03.25.10

Entity Framework

Posted in Entity Framework at 8:27 am by sa

Dem Entity Framework ein wenig auf die Finger schauen: Entity Framework Profiler.

03.09.10

LINQ Fehler

Posted in .NET, Entity Framework at 6:27 pm by sa

Der Fehler “cannot convert lambda expression to type ‘string’ because it is not a delegate type” tritt auch auf, wenn das Using Statement für System.Linq fehlt.

09.07.09

EF: Verknüpfungen zu anderen Tabellen

Posted in Development, Entity Framework at 9:26 pm by sa

Wenn man die nicht explizit lädt, sind die Eigenschaften null. Daher vor dem Zugriff mit IsLoaded Überprüfen oder direkt nachdem das Entity Objekt geladen wurde die Verknüpfungen nachladen. Ist auf jeden Fall eine Stolperfalle.

09.04.09

Abfragegeschwindigkeit

Posted in .NET, Entity Framework at 7:37 am by sa

Kollegen haben mal einen einfachen Wettbewerb Entity Framework vs. handcrafted SQL laufenlassen – ja 8. Mio DS in der Haupttabelle mit Verknüpfung. Ich hätte ja gegen EF gewettet, aber: es hat sich sehr gut gemacht. Die einfache Abfrage war bei EF deutlich effizienter als ein erster Ansatz mit T-SQL. Obwohl dieser “korrekter” (LEFT JOIN vs. Select * from (Select from * from … where …)) aussah. Gewonnen hatte handcrafted SQL als es dann darum ging die 100 Zeilen ab der 10.000. Zeile zu erfragen. Gegen eine temporäre Tabelle hatte EF da keine Chance. Bleibt abzwarten, wie’s mit EF4 wird.

08.31.09

EF: Primary Keys mit dem Datentyp Uniqueidentifier

Posted in .NET, Entity Framework at 8:31 pm by sa

Der Datentype ist zwar unterstützt, aber leider unterstützt EF NEWGUID() als Defaultvalue nicht :(

17.4.Can I use a server-generated guid as my entity key?

Unfortunately, in v1 of the EF this is not supported.  While it is possible with SQL Server to have a column of type “uniqueidentifier” and to set it’s default value to be “newid()”, with SQL Server 2000 there’s no good way to extract the value that the server generated at the time you do the insert.  This can be done on more recent versions of SQL Server, though, so the intent is that we should find a clean way to special case this support in future versions of the EF so it can be supported on those databases that allow it and not on others.  For now, the work around is to generate the guid on the client (ideally in the constructor of your object) rather than on the server.

Aus: Entity Framework FAQ