This project is read-only.

Module using Entity Framework 4.1

Topics: Customizing Orchard, Writing modules
May 26, 2011 at 12:18 PM


I was wondering if anyone can help me, I would like to create a module that uses entity framework 4.1 and code first.  I would like to do what is shown in this tutorial (  Would anyone be able to point me in the right direction? 


May 26, 2011 at 1:52 PM

Orchard has a very different database model that uses NHibernate. This allows various nifty things like having migrations that will automatically run when your module is installed. EF has no support for migrations so is neither recommended nor supported in Orchard.

Sep 20, 2011 at 9:46 PM

Is this still the recommedation for Orchard v 1.2 ?  The reason I ask is because I have written a module using EF 4.1 which seems to be working out ok so far.  I originally tried to use NHibernate until I learned that Orchard is only using v1.0 and much of what I was trying to do only worked using the latest version of NHibernate.

Are there any working modules out there that use NHibernate to connect to DB2 that use Orchard's current implementation of NHibernate ??  If not what would be the downside of using Entity Framework v4.1 inside a module in Orchard??

Thanks in advance for your responses..


Sep 20, 2011 at 9:49 PM

You won't be able to do queries across both. Otherwise, it should work.

Sep 20, 2011 at 10:23 PM

There is no downside of using the Entity Framework inside Orchard, though you just have to bear in mind that there are certain restrictions/things you just cant do without alot of extra work. Also note that unless you have enabled MSDTC you will need to Suppress all Orchard Transactions or else you will end up with problems - this is because Orchard uses a perrequest transaction model.

The latest version of NHibernate and FluentNHibernate is in the updated libs branch of Orchard, and they will be able to tell you when that will be released, I suspect v1.3.

I hope this helps.