Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add new schema to existing Visual Studio Database Project?

Tags:

I'd like to add new schema (like dbo but with different name, ex. Fruit) to database. I'm using database project in Visual Studio 2013. I have an existing database project with tables, schemas, stored procedures, pre and post deployment scripts, etc. Database project is version controlled. I'd like generating publish scripts to work nicely as it did before I added a new schema.

Creating Fruit.schema.sql in SchemaObjects/Database Level Objects/Security/Schemas with content

CREATE SCHEMA [Fruit] 

will create schema but won't add Fruit schema folder sub tree in Schema Objects/Schemas folder like dbo schema has. Should I create that subtree manually? I suspect there is smarter way to achive this.

like image 556
Fosna Avatar asked May 19 '14 11:05

Fosna


People also ask

How do I change the schema of a database?

To change the schema of a table by using SQL Server Management Studio, in Object Explorer, right-click on the table and then click Design. Press F4 to open the Properties window. In the Schema box, select a new schema. ALTER SCHEMA uses a schema level lock.


2 Answers

In Visual Studio 2017, I can add item => search for schema, and that creates a sql file that includes the line: create schema [fruit].

Then, I can reference that schema when creating other database objects.

like image 84
Zach Smith Avatar answered Oct 23 '22 17:10

Zach Smith


Yes, create the folder manually. There's no smarter way to do this :-)

like image 37
Endrju Avatar answered Oct 23 '22 15:10

Endrju