How can I set MS_Description for a database in a Visual Studio database project (or at least avoid having the build script removing the description)

Jens Gyldenkærne Jensen 20 Reputation points
2023-03-01T11:52:18.92+00:00

I'm working with a database project in Visual Studio (17.5.0). For documentation purposes I use the MS_Description property which on a column level can be set from the design window for a table using the Description column.

Describing a table is also possible using the interface since Description is shown in the Properties window for a table.

But for the database level I haven't been able to find anywhere where I can set the MS_Description/Description property. And to make things worse, If I set the property elsewhere (e.g. in Redgate SQLDoc which I use to generate documentation), it is removed once I make the next deploy.

The build script generates the following lines if it discovers the MS_Description property on the database level:

GO

PRINT N'Dropping Extended Property [MS_Description]...';

GO

EXECUTE sp_dropextendedproperty @name = N'MS_Description';

I found an option called "Drop extended properties not in source" (under Project properties>Debug>Advanced...) - but unchecking that doesn't change the behavior in regards to the database description.

Is this a bug or is there a hidden setting I haven't been able to find yet?

(If the database version is relevant it is as follows)

Microsoft SQL Server 2016 (SP2-GDR) (KB4583460) - 13.0.5103.6 (X64) Nov 1 2020 00:13:28 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor)

User's image

SQL Server Other
{count} votes

Accepted answer
  1. Seeya Xi-MSFT 16,586 Reputation points
    2023-03-02T02:29:00.19+00:00

    Hi @Jens Gyldenkærne Jensen,

    You can try adding the following SQL script to the post-deployment script for your database project:

    EXEC sys.sp_addextendedproperty

    @name=N'MS_Description',

    @value=N'Your database description goes here' ,

    @level0type=N'SCHEMA',

    @level0name=N'dbo',

    @level1type=N'DATABASE',

    @level1name=N'YourDatabaseName'

    This script will add the MS_Description property to your database after each deployment. Make sure to replace "YourDatabaseName" with the actual name of your database.

    By adding the script to the post-deployment script, you can ensure that the MS_Description property is set after each deployment and that it is not removed by the build script.

    Please refer to this document:

    https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes

    User's image

    You can post this issue to their feedback site. A fix may be available afterwards.

    Best regards,

    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.