InMemoryAuto, SourceCodeManual, SourceCodeAuto'> Getting up and running with Umbraco 9 Models Builder

Skip to the content

Getting up and running with Umbraco 9 Models Builder

I just had a play around with Umbraco 9 beta and start coming to terms with the models builder.

The good news is this was quite easy to get up and running and I also didn't find any issues. Here's how I got up and running...

What's changes since Umbraco 7 and Umbraco 8?

1. It appears the types of model builder settings have been renamed.

The model builder settings now have new names.

PureLive => InMemoryAuto

AppData => SourceCodeManual

LiveAppData => SourceCodeAuto

 

2. The model builder settings are stored in a different location.

As you probably now already know there is no web.config with Umbraco 9. So where are the appSettings stored? These are now stored in the appsettings.json file stored in the project root.

Umbraco 9 Models Builder Settings

 

3. Models are now stored in a new directory.

If you are using SourceCodeManual or SourceCodeAuto you will find the models stored within /umbraco/models/.

Umbraco 9 Models Builder Location

 

Using Umbraco 9 Models Builder

So I tested both the SourceCodeManual and the SourceCodeAuto and both worked great. I found no issues. I think I will be using the SourceCodeAuto so I dont have to keep remembering to go into Umbraco Backed / Settings / Models builder to re-build the models.

 

Changing Umbraco 9 Model Builder Directory

If you are like me and used to storing your models in a different folder or even a different project then you will want to be able to change the models builder directory. The good news this is still available in Umbraco 9. I figured it out of a little trial and error. it works great and I have had no issue since I got up and running.

To change the directory simply add a new property to the appsettings.json file.

"ModelsBuilder": {
    "ModelsMode": "SourceCodeAuto",
    "ModelsDirectory": "~/Models/ModelsBuilder/"
},

AcceptUnsafeModelsDirectory

I read a comment somewhere in the Umbraco documentation that said....

  • Fix for unsafe project names; these are no longer unsafe for namespaces.
    • E.g. "Umbraco 9" will now use namespace "Umbraco_9"

I think this is saying that if your other project namespace contains "Umbraco_9" then this will be considered a safe path. This has not been tested so don't hold me to that. I didn't find any documentation around AcceptUnsafeModelsDirectory but I am guessing the old setting will probably work.

"ModelsBuilder": {
     "ModelsMode": "SourceCodeAuto",
     "ModelsDirectory": "~/../Website.Core/Models/ModelsBuilder",
     "AcceptUnsafeModelsDirectory": true
},

**

I am just adding a further note on the bottom of here since I found some other code references regarding storing your models in a different folder. This is how to set the namespace.

**

"ModelsBuilder": {
"ModelsDirectory": "~/models/umbraco",
"ModelsNamespace": "SomeCustomNamespace.Models",
"ModelsMode": "SourceCodeAuto"
},

About the author

David Armitage

Umbraco Community Builder | .Net MVC Developer | Umbraco Certified Master | Recruitment Professional

Hey Peeps,

I'm an entrepreneur and web developer with a passion for coding. I absolutely love working with Umbraco CMS and appreciate the Umbraco community even more.

I've got 10 years+ .Net experience and 7 years+ experience working in the recruitment industry, both coding and marketing job websites. I wanted to use my skills to help give something back to this awesome community and so I decided to build UmbraJobs.com.

My vision & fundamentals

I want this website to be a place where Umbraco Professionals and Umbraco Partners can advertise their services but at the same time I want to filter out all the under-qualified freelancers & agencies that take up the biggest part of other job & freelancer websites. We've all worked hard to gain our Umbraco certifications, partnership status, and help build the Umbraco community to what it is today. I want to see everyone get rewarded for their efforts.

Follow me on social media

If you're an Umbraco professional, partner, employer, recruiter or a passionate Umbraco community builder then I'm more than happy to hear from you. Follow me on my social media channels and please reach out if you have any needs, want help or consultation with anything Umbraco related or just want a general chat.

comments powered by Disqus

Blog Filter


How we can help?

Need help with an Umbraco project?

Need help with a project but not too sure who to approach? Send us your project brief and budget. We will provide a free consultation and can help you gather quotes from the best and most suitable freelancers or agencies.

Looking to hire an Umbraco Professional?

Have you got job vacancy and want to hire an Umbraco professional? Post a job on our website for free. Alternatively let us know your requirements and we will send suitable prospects your way.

Claim your free profile!

Are you an Umbraco Freelance Developer or Umbraco partner that wants to advertise on our site? If you work with Umbraco or registered as an Umbraco partner then you can create a profile for free.

Let's build the Umbraco Community

We're big on building the Umbraco community and we think you guys are awesome! If there's anyway at all we can help then please reach out.