Upgrate from 1.5 to 1.6

Topics: Writing modules
Nov 3, 2012 at 7:37 PM
Edited Nov 3, 2012 at 7:50 PM


I upgrade site from 1.5 to 1.6 and orchard modules and my own modules works fine.

But one module stopped working.

I get 404 error on all pages (the resource cannon be found). I think this error associated with nhibrnate.

Code works with orchard 1.5. (and dont works with 1.6). I get this code from http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-9



public class OrderDetailPartRecord
        public virtual int Id { get; set; }
        public virtual int OrderPartRecord_Id { get; set; }
        public virtual int ProductId { get; set; }
        public virtual int Quantity { get; set; }
        public virtual decimal UnitPrice { get; set; }
        public virtual decimal VatRate { get; set; }

        public virtual decimal UnitVat
            get { return UnitPrice * VatRate; }

        public virtual decimal Vat
            get { return UnitVat * Quantity; }

        public virtual decimal SubTotal
            get { return UnitPrice * Quantity; }

        public virtual decimal Total
            get { return SubTotal + Vat; }




            SchemaBuilder.CreateTable("OrderDetailPartRecord", t => t
                .Column("Id", c => c.PrimaryKey().Identity())
                .Column("OrderPartRecord_Id", c => c.NotNull())
                .Column("ProductId", c => c.NotNull())
                .Column("Quantity", c => c.NotNull())
                .Column("UnitPrice", c => c.NotNull())
                .Column("VatRate", c => c.NotNull())

            SchemaBuilder.CreateForeignKey("OrderPart_CustomerPart", "OrderPartRecord", new[] { "CustomerId" }, "CustomerPartRecord", new[] { "Id" });
            SchemaBuilder.CreateForeignKey("OrderDetailPart_OrderPart", "OrderDetailPartRecord", new[] { "OrderPartRecord_Id" }, "OrderPartRecord", new[] { "Id" });
            SchemaBuilder.CreateForeignKey("OrderDetailPart_ProductPart", "OrderDetailPartRecord", new[] { "ProductId" }, "ProductPartRecord", new[] { "Id" });


If remove this model from module that module works (i dont get 404 error). If module exists only this model that module dont works (i get 404 error on all pages).

Please help me fix this error.

Nov 4, 2012 at 2:46 AM

Could you check the error logs? There should be an exception there that could help determine the exact issue.

Nov 4, 2012 at 9:10 AM
Edited Nov 4, 2012 at 9:20 AM

I check error log and fixed error. Thanks sfmskywalker.


1. NHibernate.PropertyNotFoundException: Could not find a setter for property 'UnitVat' in class 'OrderDetailPartRecord'

2. NHibernate.InvalidProxyTypeException: The following types may not be used as proxies:OrderPartRecord: method set_Details should be 'public/protected virtual' or 'protected internal virtual'

3. NHibernate.PropertyNotFoundException: Could not find a setter for property 'Total' in class 'OrderPartRecord'


for 1 and 3 - add a set property for all attributes in class OrderDetailPartRecord and OrderPartRecord without set property

set { }

for 2 - chahge private modifier to protected modifier

Nov 5, 2012 at 9:16 AM

I hit the same problems and initially I came out with the same workaround. However upon further use I realized I was then getting SQL errors when trying to view orders in the admin. The sql queries generated by the nhibernate mapping now contain the calculated fields from the OrderRecord (OrderRecord.Number, etc) and OrderDetailRecord (OrderDetailRecord.Total, etc).

What would be good in this instance would be some kind of [IgnoreField] attribute that we could decorate these public "helper" calculated getter properties with so that nHibernate auto mapping would ignore them. Maybe this exists already?

In any case I figured the cleaner approach would be to go with the way Orchard was meant to be used and make the OrderRecord an OrderPartRecord : ContentRecord with an associated OrderPart and do the same for OrderDetailRecord (OrderDetailPart and OrderDetailPartRecord). By turning the orders into orchard content items you then get all the other orchard goodness (like import/export, use of LazyField<T> in the part, etc).

I'm still in the process of going down this path, so maybe I'll hit a snag or two along the way. I'm wondering, sfmskywalker, if there's any particular reason why you didn't make the order and order detail records content parts in the first place? 

Nov 28, 2012 at 3:49 PM

I'm having the same issue. Anyone managed to solve this issue? 

After reading about this issue in NHibernate people suggesting to add something like: 

<property name="Total" type="Decimal" access="readonly"/>

Though I'm not sure where I would add that in an Orchard project?

Nov 29, 2012 at 10:41 AM

I solved this by removing the properties from the Record classes and instead created them as extension methods.

Jan 30, 2013 at 10:55 AM

mgustafsson, where did you add those extension methods? In the class itself?

Feb 7, 2013 at 3:16 PM
gmorken, i added them in a separate extensions class.