sql server - SSDT/ VS2015 Database deployment -- publishing is ignoring nested views -


i attempting gain knowledge , use cases on ssdt database development , deployments , strugling deployment issues.

specifically when using nested views. unknown reason when attempting deploy / publish files in project local / live db seems mess references in views.

in project have following views (example):

  • view1
  • view2
  • view3

view1 references view2 , view3 referencing view1.

building project works fine. hoewever when try publish database either generating dacpac snapshot , publish database or let visual studio generate update script after (or not) comparing schemas end update script tries create views in seems logical order in stored in project.

in case view1 -> view2 -> view3. means publish fails because of reference issues. can't create view if referenced view not exist.

i have tried several options adding dacpac reference in project in various ways (same database, same server different database w/ w/o database parameter) in many cases end sql71561 / sql71508 error pita solve.

online can't find sources explains how work around issue or explains how works properly.

hopefully can here. if need input side or want me try let me know.

issue has been resolved new insights. when trying build demo code share community accidentally found solution because needed clean sensitive data(model) parts. please let me elaborate on issue.

the solution can divided 2 solutions:

  • configuration of database project / solution
  • the way references work

i'll share insights on both matters.

configuration of database project / solution

the visual studio solution contained single project in views placed. actual tables , other database items separated in different solutions / project.

solution1   project1     view1     view2     view3  solution2   project1     tables     security     schemas     etc... 

the views contained three-part identifiers [database].[schema].[table/view]. both on items inside project (views) , on items outside project (tables etc.).

by using 1 separate project views led missing references. not able find other views nor tables (further see references).

one solution issue making sure both views , tables refenced in same solution / project. using three-part identifiers visual studio ignores these because of existence of items in same project / solution. detect dependencies way.

the way references work

the other way solve using references right way in visual studio. second possible solution.

considering earlier example views in different solution other elements led missing references. adding dacpac database reference setting same database led conflicting references , sql71508 element exists in model. true because exists in references dacpac , try create new view same name referencing in dacpac. because sees three-part reference variable dacpac.

when using dacpac setting same server, different database resolves mixed references because sees three-part identifiers external reference , thinks creating local copy of view looking @ external dacpac. in other words not detect nested view because thinks referencing separate database not inside project.

when building project not lead errors , deployment work. since thinks referencing external data source (in form of dacpac) not see reference other local views.

the solution (atleast worked us) use two-part identifiers in our views when need local reference other views. way @ other files inside project instead of referenced dacpac.

since detect reference other local views build correctly , detect dependancies in views inside local project. create build order views.

i guess assign different variable name referenced dacpac, use three-part-identifiers way change ones in external dacpac use newly assigned variable name. have not tested (but when home tonight).

so in learning experience in how database references work inside database projects when using partial projects or when have split database several projects / solutions. understand pandora's black box , convert them future-proof solution :)


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -