I've got my Umbraco install setup with ModelsMode set to dll and everything works fantastically well.
My issue is that for one of my pages (a Contact Form) I want to create a ViewModel that will inherit from my ContentModels.Content class allowing me to extend what I have stored within the Umbraco model with information specific to the Contact Form. However I can't figure out what namespace I need to import in order to be able to write:
public class ContactFormViewModel : ContentModels.Contact
The Developer section of Umbraco has a Models Builder tab that confirms all the current settings of the Models Builder on your site, including the name of the Models namespace:
if that is what you are after?
You can change the name of the namespace in the web.config of your site by setting an app setting value for "Umbraco.ModelsBuilder.ModelsNamespace"
Thanks Marc. I'd actually noticed the namespace and included the namespace within my model file but couldn't work out why Visual Studio couldn't see any of the models which I had presumed were going to be available. I've configured the ModelsMode to "Dll" which I had presumed would add a reference to the Umbraco.Web.PublishedContentModels dll. To get around this I've included the generated class file from AppData in my solution. Is there a better way to do this via a reference?
It depends a little on your project structure, but I tend to run ModelsBuilder in AppData mode, and then include the generated files in the app data folder in the Visual Studio solution, then you get intellisense on the model classes, and they are easy to extend via inheritence, but mainly it's easy to see in source control what changed when.
But if you have multiple projects in the solution that need to reference the models then Dll mode makes it easier to share the dll and avoid circular references.
ViewModel class to inherit from ContentModel
Hi,
I've got my Umbraco install setup with ModelsMode set to dll and everything works fantastically well.
My issue is that for one of my pages (a Contact Form) I want to create a ViewModel that will inherit from my ContentModels.Content class allowing me to extend what I have stored within the Umbraco model with information specific to the Contact Form. However I can't figure out what namespace I need to import in order to be able to write:
Is this possible? I presume it must be
Hi Craig
The Developer section of Umbraco has a Models Builder tab that confirms all the current settings of the Models Builder on your site, including the name of the Models namespace:
if that is what you are after?
You can change the name of the namespace in the web.config of your site by setting an app setting value for "Umbraco.ModelsBuilder.ModelsNamespace"
regards
Marc
Thanks Marc. I'd actually noticed the namespace and included the namespace within my model file but couldn't work out why Visual Studio couldn't see any of the models which I had presumed were going to be available. I've configured the ModelsMode to "Dll" which I had presumed would add a reference to the Umbraco.Web.PublishedContentModels dll. To get around this I've included the generated class file from AppData in my solution. Is there a better way to do this via a reference?
Hi Craig
It depends a little on your project structure, but I tend to run ModelsBuilder in AppData mode, and then include the generated files in the app data folder in the Visual Studio solution, then you get intellisense on the model classes, and they are easy to extend via inheritence, but mainly it's easy to see in source control what changed when.
But if you have multiple projects in the solution that need to reference the models then Dll mode makes it easier to share the dll and avoid circular references.
regards
Marc
is working on a reply...