views:

83

answers:

1

I am looking forward to move all the logic (which is implemented as manipulating Entity Framework 4 objects) to a server side. It looks going to be simple (thanks to the application structure) and beneficial (as all I have is one oldy laptop as a client and one tough server which runs SQL Server 2008, and building a separate service for the logic can just introduce more latency if compared to doing it inside the database).

So how do I correctly use Entities Framework inside a CLR stored procedure and make it using a host-server-provided SqlContext?

Suddenly I couldn't find any examples in the Web. Looks stragne that none has yet dine this. Does it mean that the task is ridiculous and I definitely should not do that? It won't be very convenient to use T-SQL and access tables directly instead of EF classes because my model makes heavy use of inheritance and has a very complex table-per-type structure of lots of very simple tables.

A: 

You cannot - at least not at this time. The CLR contained in SQL Server 2005 through 2008 R2 is the .NET 2.0 CLR - and Entity Framework 4 requires the .NET 4 framework.

So for now, when doing stuff inside a SQL-CLR method, you're limited to straight ADO.NET 2.0 only.

The bigger question then remains: why on earth would you want to use EF4 inside a SQL-CLR function? Those are intended to be stored proc, user-defined functions, user-defined aggregates - but certainly not full-blown database apps, really...

marc_s