prjseal / Umbraco-v8-Tutorial

21 stars 14 forks source link

Lack of strongly typed models in CleanBlog.Core #1

Open creativesuspects opened 4 years ago

creativesuspects commented 4 years ago

I've watched a couple of videos from your How to build a website with Umbraco v8 series on YouTube. You mentioned a few times that the strongly typed models weren't available in the Core project, because ModelsBuilder generates the models inside the Web project. And you were sometimes casting to strongly typed models in the views.

It would be nice to point out to people that it's fairly easy to have ModelsBuilder create the models in the Core project, so you can you use strongly typed models in both Core and Web.

~/Web.config

<add key="Umbraco.ModelsBuilder.ModelsMode" value="LiveAppData" />
<add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/../CleanBlog.Core/Models/Generated" />
<add key="Umbraco.ModelsBuilder.ModelsNamespace" value="CleanBlog.Core.Models.Generated" />
<add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true" />

~/Views/Web.config

<add namespace="CleanBlog.Core.Models.Generated" />

Keep up the good work!

prjseal commented 4 years ago

Nice tip. Thanks