Setting up a new Umbraco Site

with Model Builder Generated Models

Sunday, January 20, 2019

Initial Project Creation

In Visual Studio
Create New Project (Web Application)
- SolutionName.Web
- Choose Projects directory
- Provider Folder name as Solution Name, keep create folder for solution checked.
- Create repo Checked
- MVC & Web API

In SSMS
- Create new DB named db + SolutionName
- Create new DB user db + SOlutionName + User
-- SQL Server Authentication method
-- Uncheck Password enforcement policy
-- Configure User Mapping
--- click Reader, Writer, Owner

In VS
- via the package manager: Install-Package UmbracoCms
- You may have to update versions of any related packages to match the Umbraco package dependencies (I had to down-grade the version of Newtonsoft in from 12 to 10.3 in order to be compatable with the lates 7.x version of Umbraco...but that's about it.)
- During installation, choose to Overwrite All when prompted.

Initial Run
- when the nuget package is finished installing, click F5 to run
- this will run the site and prompt you to configure some Umbraco site setup including an initial user, db, etc.

Create a setup account:
name: setup
email: (your secondary email account)
password: (your password)
Click CUSTOMIZE, this will allow you to specify DB
- Specify DB connection info
- Create a Machine key
- Don't taked the starter template

Create yourself a user:
- name: (user name)
- password: (password)
- Administrators, Sensitive data
- save user
- in incognito mode, verify login and that everything's visible (matching against setup account)

you can now disable to setup account, if you want.

Setting up the site locally

In IIS
create a new site
update your hostfile
- may need to set specific user for IIS app pool.
- you can configure the url for your site in your webproject.

now might be a good time to checkin.

- update your gitignore file to remove all items under appdata, i have a base gitignore file that can be used for umbraco.
- review you're solution & new files. the umbraco nuget package installation you did included a lot of umbraco files used for the CMS interface, for now I include these all. This includes the App_Browsers, Umbraco and Umbraco_Client directories and all their items. Maybe I'll remove those from source control later, but I think they'll need to be included with deploys.

Setting up the Umbraco Models Builders

There are a lot of ways to configure the Umbraco Models Builder, this approach will allow generated models to be saved to a Models project in your solution, which can then be made available to any other projects. It will also generate a .cs file for each model type in the specified project & directory. 

To set this up:
- Create a new Library Projects
-- Named: {YOUR_SOLUTION}.Models
-- Create it as a Library Project (I created it as a Framework Library project)
-- Install the Umbraco.Core nuget package (you could also reference the indivual references later if you want, but i installed the whole package)
--- If you installed the Umbraco.ModelBuilder nuget package, delte the App_Plugin directory (this is included in the install, but only used for the Umbraco devdeloper tab and already included in the web project.)
-- Create a new directory under the project to store the models classes, I named this "Generated"
- Add a reference to this project to your existing Web project
- Update Web.config, replace the previous ModelBuilder appSettings with the following:

<add key="Umbraco.ModelsBuilder.Enable" value="true"/>
<add key="Umbraco.ModelsBuilder.EnableFactory" value="true"/>
<add key="Umbraco.ModelsBuilder.ModelsMode" value="LiveAppData" /> <!-- Files are updated as we save changes to the content types in the CMS. -->
<add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true"/> <!-- allows us to specify a models directory other than the default AppData directory under the web root. -->
<add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/../{YOUR_SOLUTION_NAMESPACE}.Models/Generated"/> <!-- we want the generated models in our Models project which can be accessed by all other projects. -->
<add key="Umbraco.ModelsBuilder.ModelsNamespace" value="{YOUR_SOLUTION_NAMESPACE}.Models.Generated"/>
- Log into Umbraco on your local site and go to the Developer mode
- Click on the Models Builder tab and click the "Generate Models" button
- Go back to VS, and you should now have new files under the Generated folder of your Solution.Models project, these will be the Umbraco base models
-- If you don't see them, make sure to click the "Show all files" button of your Solution Explorer and reload.
- I would like my generatd models in source control, so I include all of these files in my solution.
- Commit all changes.

Moving site to Azure

- Create a resource group for your site
- Create a new SQL Server
- Export your local database using "Export Data-Tier.."
- Import into Azure Sql Server
- Configure Azure blob storage: https://blog.nicolaayan.com/2018/05/how-to-setup-your-umbraco-media-folder-with-an-azure-storage-account/
- Create an Azure App Service for your site
- I used Visual Studio to publish my site to Azure, just had to select the Resource group and the publish settings were available. 

Setup Transforms for Release

- Replaced my FileSystemProviders line with the full FileSystemProviders configuration from the configs/FileSystemProviders.config pointing to local storage
- Added transform for this in Web.Release.config, pointing to Azure storage
- Updated connectionstrings.config to point to local db
- Added transform for this in Web.Release.config, pointing to Azure db

 

Related Content
img
Magna aliqua ut enim ad minim veniam quis nostrud.
April 18, 2016
img
Enim ad minim veniam nostrud xercitation ullamco.
April 18, 2016
img
Magna aliqua ut enim ad minim veniam quis nostrud.
April 18, 2016
img
Magna aliqua ut enim ad minim veniam quis nostrud.
April 18, 2016
Trending