Copied to clipboard

Flag this post as spam?

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


  • Andre Roussakoff 13 posts 74 karma points
    Aug 28, 2016 @ 13:04
    Andre Roussakoff
    0

    Umbraco ModelsBuilder v3 with Umbraco v7.5.2: More that one type want to be a model for content type File

    Hi, I have been developing a website for some time without using Umbraco ModelsBuilder. I have created a couple of my own models in the /Models folder: ContactModel for the custom contact form and ShowcaseProductModel for my product card. Everything went while I was developing the website in one language. Yesterday, I decided to freeze the development of the features and add two other languages using Vorto.

    So, I have studied the ModelsBuilder Wiki and have read and watched some youtube videos of Jeroen Breuer on Vorto. I liked his idea to use the Umbraco.ModelsBuilder.Api to generate models inside my /Models folder instead of inside /App_Data and/or /bin. So, I configured ModelsBuilder in the Web.config

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.EnableApi" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Nothing" />
    

    I added a dummy Paraplu.cs class inside /Models, installed the ModelsBuilder Custom Tool and configured the Properties of theParaplu.cs` to use it:

    enter image description here

    I have also added .user file with the same name as the solution ed4u.UmbracoModelsBuilder.user:

    <?xml version="1.0" encoding="utf-8"?><configuration>
      <umbraco>
        <modelsBuilder version="3.0.4.0" umbracoUrl="http://localhost:19617" umbracoUser="user" umbracoPassword="password" />
      </umbraco>
    </configuration>
    

    Immediately, I got a compilation error as my IIS Express of the Visual Studio 2015 was not running yet and there was nothing listening on port 19617. So I hit Ctrl-F5. It opened my website and I could browse it as well as my Umbraco backend.

    Back to models generation. Right clicked the Paraplu.cs file and then Run Custom Tool. I could see the model classes being generated. I have refreshed the cache in the browser and everything seemed still to be working. But I know that one can only be for 100% sure if the Visual Studio is completely restarted. So I did.

    When I opened the solution again and hit Ctrl-F5 again, it threw this error at me even before I saw the website:

    enter image description here

    The error was thrown from ModelsBuilderApplication at line 32 (the long line on the error stack trace below ModelsBuilderApplication at line 55:

    if (config.EnableFactory)
        InstallDefaultModelsFactory();
    

    I have tried a lot of things as a workaround but each time it came back to this one error message.

    I wonder if it has anything to do with the fact that I have already had 2 (not generated) models before triggering the ModelsBuilder.

  • Andre Roussakoff 13 posts 74 karma points
    Aug 28, 2016 @ 18:56
    Andre Roussakoff
    0

    Oh yeah, I have forgotten to mention. I tried to comment out File. Then it started complaining about Folder, which stands next in the list of generated models.

  • Ken Mark 82 posts 94 karma points
    Sep 28, 2016 @ 15:14
    Ken Mark
    0

    Hi, I think I have the same error. Did you manage to solve this?

  • Ken Mark 82 posts 94 karma points
    Sep 28, 2016 @ 15:25
    Ken Mark
    1

    Ah, figured it out. I shouldn't include the generated files in my solution...

  • Andre Roussakoff 13 posts 74 karma points
    Sep 28, 2016 @ 16:37
    Andre Roussakoff
    0

    Hi Ken, good to know. I have not found your fix and went an alternative way. But it would be nice to try it again and see if it works for me as well. Thanks man. :)

Please Sign in or register to post replies

Write your reply to:

Draft