Create site collection in content database
-
30-01-2021 - |
Question
I want to set by default to create a site collection in an independent content database when creating a new site collection automatically!
Ex: each content database only holds one site collection by default!
Is it possible to do that automatically without using code?
La solution
I don't think it's possible automatically.
Unfortunately, There is no event receiver triggered when creating/ created a site collection to handle this using event receiver.
However, you can adjust this manually by locking down the content database as the following:
Steps
Before creating a new site collection, you should plan to do the following:
- Lockdown all the web application content databases.
Create a new independent content database for the new Site Collection.
Create a new Site Collection will be created inside the newly created content database.
Check also Lockdown the web application content databases
Another workaround
Using PowerShell to Create a SharePoint Site Collection in an Independent Content Database
Download the full script at PowerShell: Create a SharePoint Site Collection in a Separate Content Database
Autres conseils
Yes, this is possible by overriding the class SPSiteCreationProvider. With this, you can select all of your existing content databases. If you cannot find a content database in the web application that meets the criteria, you could then create a new content database.
You should be aware that this would slow down the site creation process significantly as provisioning a new content database isn't an instant process.
I'm linking to Wictor's article below which references HNSC, but this will also apply to path-based site collections.