locked
How to use the Database Deployment API to deploy databases from .dbschema files that have references to other .dbschema files? RRS feed

  • Question

  • Hi!

    I have followed Barclay Hill's example on how to use the Database Deployment API, and successfully implemented it myself. I have verified that it works with the sample .dbschema-file provided in the sample, and I can also deploy one of my own .dbschema-files. However, I have trouble deploying two other .dbschema-files I have. The reason seems to be that I have elements in my .dbschema file that reference another .dbschema file.

    My project structure is that I have one Server-project that contains my sql logins, and 3 other Database-projects that reference the Server-project. The reason I can deploy one of them is that it's a new project that I haven't added users to yet. The users in the two other projects are linked to the logins defined in the Server-project, and this seems to be the problem when I try to deploy them. When I run I get an exception:

    Microsoft.Data.Schema.Build.DeploymentFailedException: Errors occurred while modeling the target database. Deployment can not continue.
       at Microsoft.Data.Schema.Build.SchemaDeployment.PrepareModels()
       at Microsoft.Data.Schema.Build.SchemaDeployment.Execute(Boolean executeDeployment)
       at Microsoft.Data.Schema.Build.SchemaDeployment.CreateController()
       at MyNameSpace.DatabaseCreator.CreateDatabase(String targetDatabaseName, String connectionString, String modelFilePath) in Path\DatabaseCreator.cs:line 82

    After scratching my head and googling for answers without finding anything useful, I came to think of the ErrorManager object that was used in the sample. So I looked at the error messages from errorManager.GetAllErrors() and this is what I got:

    ErrorSeverity: Error
    ErrorPrefix: TSD
    ErrorCode: 0
    BuildErrorCode: TSD00000
    Message: The reference to external elements from the source named 'RmsVDBServer.dbschema' could not be resolved, because no such source is loaded.
    Document: Path\RmsVMain.dbschema
    Line: 16087
    Column: 7

    ErrorSeverity: Error
    ErrorPrefix: TSD
    ErrorCode: 0
    BuildErrorCode: TSD00000
    Message: The reference to external elements from the source named 'RmsVDBServer.dbschema' could not be resolved, because no such source is loaded.
    Document: Path\RmsVMain.dbschema
    Line: 16112
    Column: 7

    So my question to you now is how do I load my RmsVDBServer.dbschema file together with my RmsVMain.dbschema file? (I'm just guessing that this is what I have to do to make things work.)

    • Edited by Sub-Star Sunday, July 18, 2010 1:15 AM corrected small typo
    Tuesday, July 13, 2010 8:42 PM

Answers

All replies

  • Hi,

    Have you referenced RmsVDBServer project and its referencing projects in your database project?

    If project A references project B and project B references project C, project A must reference both project B and C. It is by design.

    Please let me know if it can help to fix the issue. Thanks.


    Looking for TFS Hot Issues? Follow us at Twitter.

    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, July 16, 2010 1:43 AM
    Moderator
  • Hi Hongye,

    I'm sorry if I wasn't clear.

    In my case both project B and project C have a reference to project A. Project A does not have any references to other projects. Or to rephrase; RmsVDBServer does not have any references to other projects. RmsVMain and the two other projects reference RmsVDBServer.

    The database projects all build completely fine. This is not where the problem is. My problem is when I try to programmatically deploy the .dbschema file to the sql-server using Barclay Hill's example (see link in my original post).

    I don't know how to load more than one .dbshcema-file to the deployment engine from code, to make it resolve the references. Anybody know how to do that? Barclay?

    Sunday, July 18, 2010 1:14 AM
  • I thought I should add that I got this to work by following Barclays second blog post on the topic. Thanks Barclay! =)
    • Marked as answer by Sub-Star Thursday, October 28, 2010 9:29 AM
    Thursday, October 28, 2010 9:29 AM