Where does Orchard store NHibernate mappings?

Topics: Customizing Orchard, Writing modules
Dec 16, 2012 at 8:29 PM

Hi,

During development of my first orchard module (area, not a content type or widget) I've updated the content of migrations.cs file without upgrading the version (don't see the need before something is released).

To force migrations to occur again, I removed the table from my SQL Server database and deleted the record in table 'Orchard_Framework_DataMigrationRecord'.

The migrations.cs file runs and the updated version of my table is created.

However, NHibernate seems to recognize only the fields that were present in the first version of migrations.cs.

How does the mapping work? I assume it is cached somewhere?

 

Coordinator
Dec 16, 2012 at 9:50 PM

mappings.bin in your site folder under app_data.

Dec 17, 2012 at 6:42 AM

Yes, I saw this file was mentioned in the docs. I renamed it to see if it changed anything, but it didn't (didn't get rebuilt nor did NHibernate act differently).

Do I need to delete this file and run migrations.cs again to get it rebuilt?

Dec 17, 2012 at 6:59 AM

Did you restart the webserver? It does recreate for me if I remove it.

Dec 17, 2012 at 7:19 AM

I didn't. I will try this later today.

Thanks, both!

Coordinator
Dec 17, 2012 at 7:45 AM

Mappings are generated at startup based on enabled modules. The mappings are cached in mappings.bin, and a checksum is generated. Altering a record or a module will change this checksum and regenerate this file/mapping.

Dec 17, 2012 at 6:38 PM

Yes, it's working.

I removed my table, removed its record in table 'Orchard_Framework_DataMigrationRecord', deleted mappings.bin and restarted IIS.

When starting up Orchard, migrations.cs ran and mappings.bin was recreated. And sure enough, NHibernate now works with all fields!

Thanks, all!

 

Dec 30, 2012 at 11:26 PM

Worked for me too! Happy days! :-)