This project is read-only.

Altering a module that has data access

Topics: General, Writing modules
May 1, 2012 at 2:42 AM

Hi all,

I'm trying to add a new field to the image gallery module (mello) and it's all fine except I can't seem to get it to write the value back to the database.

It's just a field called Link and is a string. I'll post the code if necessary but I think I must be missing something simple.

I've read over the Understanding data access document and even put an UpdateFrom3 method in the migration.cs file however the 'Some features need to be upgraded' notification doesn't even appear. Not sure but maybe this is a symptom of my problem.



May 1, 2012 at 2:46 AM

You mean a property?

Since 1.4, migrations run silently and automatically, so it's normal that you wouldn't get a notification. Check the DB directly to see if it changed.

May 1, 2012 at 3:01 AM

Hi Bertrand,

Yep, a property.

It has created the field in the database, awesome. I see there's an Edit this page on the documentation. Can I update it or do I need access?

Any ideas why the Repository update (and create) are not updating the db field?



May 1, 2012 at 4:37 AM

You can edit. That will make a pull request, and when that gets accepted, the site gets updated.

If you wired your repository correctly in your handler, any change to a part would get persisted automatically, unless there is an exception rolling back the transaction. So either you didn't wire the repo correctly, or there is an exception preventing the persistence from happening. Look for it in your app_data\logs.

May 1, 2012 at 11:02 PM

There's nothing related in the logs.

Ok, something strange going on here. I deployed the site to the test server and the data persistence is working correctly there, just not in my localhost. It's neither reading or writing to the database locally (shared database, connectionstring details). Is it possible that there's something loaded in memory somewhere that could be ignoring the change locally? I've cleaned, rebuild, application restart (by altering global.asax), even deleted the Mello.ImageGallery.dll from the bin folder. When I debug locally I hit the breakpoints and can see the property being populated correctly so the symbols are loading.

May 1, 2012 at 11:28 PM

Anything in app_data\logs?

May 1, 2012 at 11:39 PM

Nothing in the logs. The debug & error logs for today are empty

May 2, 2012 at 12:15 AM

Just for that module? Others persist fine? Did you try to contact the author of the module?

May 2, 2012 at 12:24 AM

Just for the newly added property on that module. All other properties persist fine locally.

I'll put a discussion up on to point Gabriel at this discussion. It seems to me like it's more likely to be some anomaly with one of the frameworks though.

Thanks Bertrand.


May 2, 2012 at 12:27 AM

Aaaaaah. Well, yes, delete mappings.bin in app_data and let's see if that makes a difference.

May 2, 2012 at 12:49 AM


Deleted Orchard\src\Orchard.Web\App_Data\Sites\Default\mappings.bin, stopped the web dev server and restarted debugging and it works now.

Thanks again for your help.