Title: umbracoFile property empty
Tags: razor;umbraco
Question: I manage to successfully upgrade Umbraco from 4.0.3 to 4.11.10. I have 100's of xslt files in the older version and in umbracoSettings.config file I have used  "UseLegacyXmlSchema" to be true. Every thing is working except when I wrote a simple razor macro below and noticed @photo.umbracoFile is always null or empty. I found this article http://allan-laustsen.blogspot.co.uk/2012/04/umbraco-razor-dynamicmedia-umbracofile.html but the solution is a bit confusing. I wonder if any one can help on this?

```@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext            
@{
//Check the currentpage has a value in the property 'photos'
if (Model.HasValue("sliderImages"))
{

    var MediaFolder = Library.MediaById(Model.sliderImages);

            <ul&gt;

              @foreach (var photo in MediaFolder.Children)
                {
                 <li &gt;
                        <img src="@photo.umbracoFile" alt="@photo.Name"  /&gt;

                 </li&gt;
                }

            </ul&gt;

      }
```

}

Comment: This has occurred to me occasionally and usually it was a problem with Examine. Re-saving the media files was what fixed it for me. Usually I write a script that iterates through them and saves them.


Here is another answer: Up to version 4.7 (I think), each rendering of a ```Media``` item made a call to the database. The model changed to indexing all media into the Lucene indexes much in the same way that content nodes are, and then each rendering of an image just made a call to the index. This of course made it substantially faster.

During the upgrade the media files were probably not indexed. The content will already have been indexed so this wouldn't have been an issue. So, the solution would just be to republished the entire site. This will ensure that any images referenced by the content are indexed.

Comment for this answer: Thanks for the Comment. I tried the following to republish but it does not seem to make any difference.
Comment for this answer: AFAIK that only republishes the content nodes and doesn't include the media nodes.

Here is another answer: I know this is old, but since I just ran into this exact issue I thought I'd add that to republish media nodes, the only thing I've found to work is to sort and save a given parent node, republishing the whole site seems to only republish content nodes. I sort the parent media directory of the files that are experiencing this issue alphabetically and then save the new order - this allows references to .umbracoFile in razor again (i.e. the property on the affected files is no longer empty, but instead contains the path as expected).

In my case ```<UseLegacyXmlSchema&gt;``` was already set to false and rebuilding the indexes did not work either.

Comment for this answer: Thanks SO MUCH for this solution! I just had to do this on EVERY FOLDER in our media tree. There were a lot of folders. I am now mad about this. Is this bug logged do you know?

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:07/22/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<razor><umbraco>', 'Title': 'umbracoFile property empty', 'ViewCount': 1347, 'id': 17789524, 'user_AboutMe': '', 'user_AccountId': 1044974.0, 'user_DisplayName': 'rumi', 'user_Reputation': 3111.0, 'user_Views': 314.0, 'user_id': 1050179.0}}