Search code examples
.netsql-serverentity-frameworkstored-proceduressqlclr

How do I use Entity Framework in a CLR stored procedure?


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.


Solution

  • No, you can't. Visual Studio wouldn't even let you add the file or project type. (That's too bad, I wanted to do that also to process some really complex logic.)