locked
Role memberships get dropped RRS feed

  • Question

  • I have a solution that is made up of multiple composite projects. I have one project RBSecurity containing the security objects - users, roles and role memberships. I have another project RBDatabase containing the user objects and code: tables, views, functions, procs etc.
    The RBDatabase project makes a reference to the RBSecurity project.
    The deploy order is such: RBSecurity Project, RBDatabase Project.
    The RBDatabase project has the 'Drop objects in target but not in project' option checked / enabled.
    When I deploy the RBDatabase project (NOTE: I don't deploy the solution - I only deploy the project), the role memberships defined in the RBSecurity project get dropped .
    Why should that happen ? Since the RBSecurity project is a composite project, all the objects contained within it should be considered part of the complete database model. It appears though that the RBDatabase project is not aware of the existence of the role memberships and therefore drops them from the target during the deploy because of the Drop setting being enabled. No other objects are being dropped - only the role memberships.
    I checked the project settings to verify if the option 'Ignore role memberships' was enabled - but that was not the case.
    Can you please explain this behavior ?
    Friday, October 23, 2009 3:07 PM

Answers

  • You need to uncheck/disable "Drop objects in target but not in project" for RBDatabase.

    Defining a reference from one project to another does not cause the objects defined in the referenced project to be included in the database model of the referencing project. When you deploy each project only the objects defined in that project are modeled and compared with the target database.


    Duke Kamstra - Program Manager - VSTS Database Edition (Data Dude, DBPro)
    Monday, October 26, 2009 8:09 PM
    Moderator

All replies

  • Hi,

    You can build the project again and look at the sql code that is created - that should give you more details. If you cannot find the problem, can you just post the sql?

    Thanks,
    Alin,
    PRAKTIK Consulting
    TFS Hosting and TFS Consulting Services.
    Friday, October 23, 2009 4:31 PM
  • You need to uncheck/disable "Drop objects in target but not in project" for RBDatabase.

    Defining a reference from one project to another does not cause the objects defined in the referenced project to be included in the database model of the referencing project. When you deploy each project only the objects defined in that project are modeled and compared with the target database.


    Duke Kamstra - Program Manager - VSTS Database Edition (Data Dude, DBPro)
    Monday, October 26, 2009 8:09 PM
    Moderator
  • That does not make sense. If that was the case, then I should have seen all objects that were not part of the project currently being deployed getting dropped. But, in my case, only the role memberships were getting dropped.

    If that statement is true, then that could be a huge problem when using composite projects and database references.
    So if Project A references Project B and Project B references Project C, the order of deployment will be :
    Project C
    Project B
    Project A

    If the statement you make is indeed true, then when Project B gets deployed (with the "drop objects option enabled"), then would all the objects included within Project C get dropped by deployment of Project B ?


    Thursday, November 5, 2009 8:23 PM
  • Actually, in the scenario you described, Project B contains all of the elements of Project C due to the composite relationship.  But, it doesn't contain the objects in Project A.  So, when Project B is deployed with the Generate Drop statements option enabled, all of the objects in Project A will be removed from the target database.  The subsequent deployment of Project A would recreate the objects in Project A.

    The correct way to handle this situation if you want to generate drop statements is to only configure the most derived database to generate drop statements.

    Andrew
    Tuesday, November 24, 2009 8:17 PM