Partial Visual Studio Database Pro Project Issues

In the Visual Studio 2008 Database, you can use "partial projects" so that you can split the database into several projects for deployment and maintenance. I studied this using our project, but clicked the following snag:

If you have a project that defines some base tables, and then you have another project that defines a new set of tables with constraints pointing to the tables in the first project, DBPro seems unable to match this relationship. Specific error:

"CONSTRAINT has an unresolved reference to table foo" (where foo is in the source database).

A more specific example, if you want to duplicate a script for yourself:

  • Create a project called BaseDB.

  • Define a table in BaseDB called Users with the following DDL:

    CREATE TABLE [dbo].[Users] ( 
        UserID INT IDENTITY(1,1) PRIMARY KEY, 
        UserName NVARCHAR(20) NOT NULL
    )
    
  • Export BaseDB as a partial project adding the _BaseDB.files file to your project.

  • Create a project in the same solution as DerivedDB

  • Use the Partial Import Project to point to BaseDB, confirming if you like that your import files have a link to a stub pointing to the Users table in BaseDB.

  • Define a table in DerivedDB called PowerUsers with the following DDL:

    CREATE TABLE [dbo].[PowerUsers] ( 
        PowerUserID INT IDENTITY(1,1) PRIMARY KEY, 
        UserID INT NOT NULL
    )
    
  • If you perform the “build” at this point, everything works.

  • Add FOREIGN KEY CONSTRAINT in the PowerUsers DerivedDB project for users with the following DDL:

    ALTER TABLE [dbo].[PowerUsers]
        ADD CONSTRAINT [PowerUsers_Users_FK]
        FOREIGN KEY (UserID)
        REFERENCES [dbo].[Users] (UserID)
    

Following the above steps should allow you to see the error I'm talking about.

Questions:

  • Is there a way to fix constraint links in database projects?

  • , , DDL ?

+3

Source: https://habr.com/ru/post/1702386/


All Articles