Skip to content

A template-based .Net Core 8 MVC CMS built with C#, SQL server, and JQuery, providing an intuitive WYSIWYG/drag and drop edit experience. Supports multi-tenant webroot and database.

License

ninianne98/CarrotCakeCMS-Core

Repository files navigation

CarrotCakeCMS (MVC Core)

Source code for CarrotCakeCMS (MVC - Core), .Net Core 8

Welcome to the GitHub project for CarrotCake CMS MVC Core, an open source c# project. CarrotCake is a template-based MVC .Net Core CMS (content management system) built with C#, SQL server, jQueryUI, and TinyMCE. This content management system supports multi-tenant webroots with shared databases.

If you have found this tool useful please contact us.

Source code and documentation is available on GitHub and SourceForge. Documentation and assemblies can be found here.

Some features include: blogging engine, configurable date based blog post URLs, blog post content association with categories and tags, assignment/customization of category and tag URL patterns, simple content feedback collection and review, blog post pagination/indexes (with templating support), designation of default listing blog page (required to make search, category links, or tag links function), URL date formatting patterns, RSS feed support for posts and pages, import and export of site content, and import of content from WordPress XML export files.

Other features also include date based release and retirement of content - allowing you to queue up content to appear or disappear from your site on a pre-arranged schedule, site time-zone designation, site search, and ability to rename the administration folder. Supports the use of layout views to provide re-use when designing content view templates.


CarrotCakeCMS (MVC Core) Developer Quick Start Guide

Copyright (c) 2011, 2015, 2023, 2024 Samantha Copeland Licensed under the MIT or GPL v3 License

CarrotCakeCMS (MVC Core) is maintained by Samantha Copeland

Install Development Tools

  1. Visual Studio Community/Pro/Enterprise (VS 2022 Community) Typically being developed on VS 2022 Enterprise. Requires patch version 17.8 or later, for .Net 8 support.
  2. SQL Server Express 2016 (or higher/later) - currently vetted on 2016 Express. Entity Framework Core 8 does not work with older versions of SQL Server, such as 2014/2012/2008R2 and earlier.
  3. SQL Server Management Studio (SSMS) - required for managing the database

Get the Source Code

  1. Go to the repository (GitHub or SourceForge) in a browser

  2. Download either a GIT or ZIP archive or connect using either a GIT or SVN client

Open the Project

  1. Start Visual Studio

  2. Open CarrotCakeCoreMVC.sln solution in the root of the repository

    Note: If your file extensions are hidden, you will not see the ".sln" Other SLN files are demo widgets for how to wire in custom code/extensions

  3. Edit appsettings.json under CMSAdmin root directory (this corresponds to the CMSAdminCore project)

    • In the ConnectionStrings section, configure the CarrotwareCMS value to point to your server and the name of your database. Note: the credentials require database owner/dbo level as it will create the database artifacts for you.
    • In the SmtpSettings, configure the pickupDirectoryLocation to a directory on your development machine (for testing purposes).
  4. Right-click on CMSAdminCore and select Set as StartUp Project

  5. Right-click on CMSAdminCore and select Rebuild. The project should download all required NuGet packages and compile successfully

    There may be some warnings, you can ignore them

  6. SQL Server should be running with an empty database matching the one specified in the connection string. If you are running the code a second or later time, it will auto update if there are schema changes (see dbo note above).

    • Do not share a database between the Core, MVC 5, and WebForms editions. You can update the schema if you want to upgrade and take your existing data to the newer version.
    • If you manually add the first EF migration to an existing MVC5 version of this CMS, it will automatically migrate the data.
    • Password hashes will not be valid when upgrading MVC 5 (or MVC Core 6) to MVC Core 8, so perform a password recovery to set valid ones.

Make a backup FIRST when upgrading!

-- if you are coming from a database older than SQL 2016 as an upgrade from an earlier CMS version and are upgrading to SQL 2016 or later, run a compatibility update
-- https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level?view=sql-server-ver16
-- COMPATIBILITY_LEVEL { 160 | 150 | 140 | 130 | 120 | 110 | 100 | 90 | 80 }
-- *REQUIRED* if seeing "SqlException: Incorrect syntax near the keyword 'WITH'. Incorrect syntax near the keyword 'with'. "

ALTER DATABASE [CarrotCoreMVC]
	SET COMPATIBILITY_LEVEL =  130        -- SQL 2016

-- if you plan to use an existing database from the MVC 5 version, you will need to have some entries in the migrations table
-- password hashes from MVC 5 will be invalid, perform a password recovery to set valid ones

-- to create the migrations table:

CREATE TABLE [dbo].[__EFMigrationsHistory](
	[MigrationId] [nvarchar](150) NOT NULL,
	[ProductVersion] [nvarchar](32) NOT NULL,
 CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY CLUSTERED 
(
	[MigrationId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

-- main CMS MVC 5-> MVC Core 8 - create the ef table (if needed) and execute the insert for 00000000000000_Initial
-- the password hashes will be incorrect, so perform a password reset once the DB has been upgraded
IF (NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] where [MigrationId]='00000000000000_Initial')
			AND EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[membership_User]') AND type in (N'U'))) BEGIN
	insert into [__EFMigrationsHistory]([MigrationId],[ProductVersion])
		values ('00000000000000_Initial','8.0.0')
END

-- photo gallery widget - create the ef table (if needed) and execute the insert for 20230625212349_InitialGallery
IF (NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] where [MigrationId]='20230625212349_InitialGallery')
			AND EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblGallery]') AND type in (N'U'))) BEGIN
	insert into [__EFMigrationsHistory]([MigrationId],[ProductVersion])
		values ('20230625212349_InitialGallery','8.0.0')
END

-- simple calendar widget - create the ef table (if needed) and execute the insert for 20230709210325_InitialCalendar
IF (NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] where [MigrationId]='20230709210325_InitialCalendar')
			AND EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblGallery]') AND type in (N'U'))) BEGIN
	insert into [__EFMigrationsHistory]([MigrationId],[ProductVersion])
		values ('20230709210325_InitialCalendar','8.0.0')
END

-- event calendar widget - create the ef table (if needed) and execute the insert for 20230723225354_InitialEventCalendar
IF (NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] where [MigrationId]='20230723225354_InitialEventCalendar')
			AND EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblGallery]') AND type in (N'U'))) BEGIN
	insert into [__EFMigrationsHistory]([MigrationId],[ProductVersion])
		values ('20230723225354_InitialEventCalendar','8.0.0')
END

-- faq widget - create the ef table (if needed) and execute the insert for 20240421191144_InitialFaq2
IF (NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] where [MigrationId]='20240421191144_InitialFaq2')
			AND EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[carrot_FaqCategory]') AND type in (N'U'))) BEGIN
	insert into [__EFMigrationsHistory]([MigrationId],[ProductVersion])
		values ('20240421191144_InitialFaq2','8.0.0')
END

-- to validate
select * from [__EFMigrationsHistory] where [MigrationId] like '%Initial%'
  1. if the database is empty or has pending database changes, the EF migrations will be automatically applied.

  2. The first time you start up the website, it will create the required artifacts in the database (tables/views/sprocs etc.)

  3. Click the Play button (or hit F5) in the main toolbar to launch CarrotCakeCMS

  4. When you run the website with an empty user database, you will be prompted to create the first user

  5. Once you have created a user, you can go to the login screen, enter the credentials

  6. After successfully logging in, you can create and manage your new website

Using CarrotCakeCMS Core

For additional information on how to use CarrotCakeCMS, please see the CarrotCakeCMS Documentation.