Azure SQL set default Collation

azure-sql-database entity-framework-core

Question

The default collation for Azure SQL is SQL_Latin1_General_CP1_CI_AS, not too good if your language has accents or diacritics and you want to ignore them. Everytime I want to deploy a web application with database to Azure I'm forced to create the database manually and set the collation in that moment. If this database needs to be dropped for any reason I have to keep in mind that it has to be created manually again to set the collation and the price level.

I would like to use the Entity Framework Core methods for creating from scratch the database and set the collation from there (EnsureDatabaseCreated and Migrate), but I think this is not possible at the moment and, given the speed the Entity Framework is being developed it probably won't be until year 2035.

So, the best solution is setting the default collation on the server instance (so the new database created on it would get this default) but there is no option when you create it... I know this can be done for a "normal" SQL Server instance but, does anybody know if it is possible for a SaaS Azure SQL Server instance? If so, how?

Popular Answer

As of today, you cannot change the collation of the Azure SQL DB Server - only the database.

That said you can can use EF to run a T-SQL Statement to change the collation of the Azure SQL DB by running something like this:

USE master;
GO
ALTER DATABASE MyOptionsTest
COLLATE French_CI_AS ;
GO



Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow