Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Andy 13 posts 54 karma points
    Apr 02, 2020 @ 13:01

    what does the model.generated.cs file do in Umbraco?

    Exploring Umbraco 8 and playing around building a test site etc.

    Building document types and content pages via the back office interface, and looking in the code itself I've noticed a files called models.generated.cs.

    looking inside, it contains partial classes like: public partial class AndyTestPage : PublishedContentModel { }

    and properties I've given it like :

    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder", "8.5.5")] [ImplementPropertyType("andyProperty1")] public string AndyProperty1 => this.Value

    my question is, what exactly is the point of this file? what does is do and how are these properties and classes created in here via the backoffice cms.

    second question is, how would I go about creating a document type, and properties from code? my noob assumption is to simply add the classes in the this file, but that doesnt seem right?



  • Matthew Wise 265 posts 1282 karma points MVP 3x c-trib
    Apr 02, 2020 @ 14:23
    Matthew Wise

    Models builder only creates classes from the back office and not from code.

    So the simple answer right now is you can't.

    Long answer is you could extend it to do (I have no idea how)


Please Sign in or register to post replies

Write your reply to: