Copied to clipboard

Flag this post as spam?

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


  • ThomasBrunbjerg 90 posts 182 karma points
    Sep 05, 2017 @ 09:02
    ThomasBrunbjerg
    0

    Can't use @model with @inherit

    I've implemented Entity Framework into my project, since I need to insert some data via a form to a custom table in my SQL database.

    I've scaffolded all the CRUD views and have a button that links to the create view. This all works well and fine, but I need the create view to use the Master template that contains my header, navigation and footer.

    In my create view I need to import my model, but I am unable to both use the @model and the @inherit keywords in the same file, so I am unable to inherit the master template.

    Is it not possible to use Entity Framework with Umbraco? Do I need to create a partial view or Macro?

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Sep 05, 2017 @ 09:05
    Alex Skrypnyk
    0

    Hi thomas

    You can use Entity Framework with Umbraco, you can use what you want with Umbraco :)

    There is a PetaPOCO mini ORM in Umbraco, often it's enough.

    Thanks,

    Alex

  • ThomasBrunbjerg 90 posts 182 karma points
    Sep 05, 2017 @ 09:12
    ThomasBrunbjerg
    0

    Thanks, but where would i place my markup for the Create view to make it inherit from my master template?

    I cannot use @model and @inherit in the same file.

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Sep 05, 2017 @ 13:51
    Alex Skrypnyk
    0

    But you can use:

    @inherits UmbracoViewPage<ModelClass>
    
  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Sep 05, 2017 @ 14:10
    Nik
    1

    Hi Thomas,

    Alex's explination is correct, you would use @inherits UmbracoViewPage

    Both of Umbraco base view pages (UmbracoViewPage and UmbracoTemplatePage) allow you to specify the model, although the UmbracoTemplatePage insists that your model inherits from Umbracos RenderModel object.

    Thanks,

    Nik

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Sep 05, 2017 @ 13:44
    Paul Seal
    0

    '''@inherits UmbracoViewPage

Please Sign in or register to post replies

Write your reply to:

Draft