VS 2017 Database Project «неразрешенная ссылка на объект» Ошибка - PullRequest
0 голосов
/ 27 июня 2018

Инструменты данных Microsoft SQL Server для Visual Studio 2017 (SSDT) ​​версии 15.7.4

У меня есть хранилище данных, которым я хочу управлять с помощью проекта (ов) SSDT SQL Server Database (SSDb). DW имеет отдельные базы данных Extract / Cleanse / Transform / DataWarehouse. У меня есть несколько SP и UDF в мастер БД. SP помечены как системные процедуры через sp_MS_marksystemobject. Эти универсальные SP и UDF могут использоваться во всех базах данных DW.

Я создал проект SSDb для каждой базы данных, добавил ссылку на master (как с флажком «Подавлять ошибки», так и без него) и импортировал объекты моей базы данных со всеми параметрами (объектами). Я также выбрал Инструменты - -> Параметры -> Инструменты SQL Server -> Онлайн-редактирование -> Разрешить ссылки на системные представления и основные объекты базы данных. Я перезагрузил и восстановил SSDT.

Я получаю эти ошибки:

------ Build started: Project: MyDWName, Configuration: Debug Any CPU ------
        C:\Program Files (x86)\Microsoft Visual Studio\2017\SQL\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /debug+ /debug:full /optimize- /out:obj\Debug\MyDWName.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\SQL\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /warnaserror- /utf8output "C:\Users\FUBAR\AppData\Local\Temp\.NETFramework,Version=v4.5.SqlClrAttributes.cs"
        Loading project references...
        Loading project files...
        Building the project model and resolving object interdependencies...
        Validating the project model...
Y:\SSIS\MySSDTSolution\MyDWName\Security\SAS_SQL_Admin.sql(1,1): Error:  SQL71501: User: [SAS_SQL_Admin] has an unresolved reference to Login [SAS_SQL_Admin].
Y:\SSIS\MySSDTSolution\MyDWName\Security\DOMAIN_user.sql(1,13): Error:  SQL70527: 'DOMAIN\user' is not a valid name because it contains characters that are not valid.
Y:\SSIS\MySSDTSolution\MyDWName\Security\DOMAIN_anotheruser.sql(2,27): Warning:  SQL71502: User: [DOMAIN\anotheruser] has an unresolved reference to Schema [DOMAIN\anotheruser].
Y:\SSIS\MySSDTSolution\MyDWName\dbo\Stored Procedures\uspDeleteTempTables.sql(10,67): Warning:  SQL71502: Procedure: [dbo].[uspDeleteTempTables] has an unresolved reference to object [sys].[sysprocesses].[spid].
Y:\SSIS\MySSDTSolution\MyDWName\dbo\Stored Procedures\uspDeleteTempTables.sql(10,26): Warning:  SQL71502: Procedure: [dbo].[uspDeleteTempTables] has an unresolved reference to object [sys].[sysprocesses].[nt_username].
Y:\SSIS\MySSDTSolution\MyDWName\dbo\Stored Procedures\uspDeleteTempTables.sql(10,44): Warning:  SQL71502: Procedure: [dbo].[uspDeleteTempTables] has an unresolved reference to object [sys].[sysprocesses].
Done building project "MyDWName.sqlproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Для предупреждения процедуры SQL71502, если я изменю sys.sysprocesses на master.sys.sysprocesses, предупреждение исчезнет. Но у меня есть ссылка на мастера, разве это не работает ???

Для ошибки SQL71501 я не вижу недопустимых символов в имени пользователя. Если я вставлю точный код в SSMS, ошибок не будет. У других пользователей такой же синтаксис DOMAIN \ username без ошибок.

В случае ошибки SQL70527 это пользователь со схемой по умолчанию dbo, а также с собственной схемой и членством db_owner. Импортированный текст был:

CREATE USER [SAS_SQL_Admin];

Однако, сценарий этого пользователя в SSMS:

CREATE USER [SAS_SQL_Admin] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo];

При вставке этого текста в SSDT ошибка исчезла. Три часа поиска в Google, одна проблема решена. Это ошибка в SSDT? Разве он не должен импортировать то же определение, которое генерирует SSMS?

В другом проекте SSDb я получаю следующие ошибки:

------ Build started: Project: MyDb (Databases\MyDb), Configuration: Debug Any CPU ------
        C:\Program Files (x86)\Microsoft Visual Studio\2017\SQL\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" /debug+ /debug:full /optimize- /out:obj\Debug\RLDX_Extract.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\SQL\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /warnaserror- /utf8output "C:\Users\FUBAR\AppData\Local\Temp\.NETFramework,Version=v4.6.1.SqlClrAttributes.cs"
        Loading project references...
        Loading project files...
        Building the project model and resolving object interdependencies...
        Validating the project model...
Y:\SSIS\MySSDTSolution\MyDWName\MyDb\meta\Views\vwJob_Status_Comma.sql(9,8): Error:  SQL71501: View: [meta].[vwJob_Status_Comma] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [master].[dbo].[fn_MoH_RightJustify] or [meta].[Job_Status].[master]::[dbo].[fn_MoH_RightJustify].
Y:\SSIS\MySSDTSolution2\MyDWName2\RLDX_Extract\meta\Views\vwJob_Status_Comma.sql(13,8): Error:  SQL71501: View: [meta].[vwJob_Status_Comma] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [master].[dbo].[fn_MoH_RightJustify] or [meta].[Job_Status].[master]::[dbo].[fn_MoH_RightJustify].
...
Y:\SSIS\MySSDTSolution\MyDWName\MyDb\Security\NSWDOH_anotheruser.sql(2,27): Warning:  SQL71502: User: [NSWDOH\anotheruser] has an unresolved reference to Schema [NSWDOH\anotheruser].
Done building project "RLDX_MyDb.sqlproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Вот определение вида:

CREATE VIEW [meta].[vwJob_Status_Comma] AS
SELECT Job_ID
    ,Job_Level
    ,Job_Name
    ,Job_RunDate
    ,Job_StartTime
    ,Job_EndTime
    ,master.dbo.fn_MoH_RightJustify(FORMAT(Job_ElapsedSeconds,'N0'),18,DEFAULT) AS Job_ElapsedSeconds
    ,Job_ElapsedTime
    ,DataExtract_StartTime
    ,DataExtract_EndTime
    ,master.dbo.fn_MoH_RightJustify(FORMAT(RowCountSource,'N0'),15,DEFAULT) AS RowCountSource
    ,master.dbo.fn_MoH_RightJustify(FORMAT(RowCountInserted,'N0'),15,DEFAULT) AS RowCountInserted
    ,master.dbo.fn_MoH_RightJustify(FORMAT(RowCountChanged,'N0'),15,DEFAULT) AS RowCountChanged
    ,master.dbo.fn_MoH_RightJustify(FORMAT(RowCountNoChange,'N0'),15,DEFAULT) AS RowCountNoChange
    ,master.dbo.fn_MoH_RightJustify(FORMAT(RowCountDeleted,'N0'),15,DEFAULT) AS RowCountDeleted
    ,master.dbo.fn_MoH_RightJustify(FORMAT(RowCountTarget,'N0'),15,DEFAULT) AS RowCountTarget
    ,Job_Step
    ,Job_Status
    ,SubmittedBy
FROM meta.Job_Status

Вопросы:

1) Любая идея, почему действительный пользовательский объект в SSMS сгенерирует эту ошибку в SSDT:

'DOMAIN \ user' не является допустимым именем, поскольку оно содержит недопустимые символы.

2) Я хотел бы управлять объектами пользователя в проекте SSDT. Я предпочитаю видимость объектов в проекте. Это плохая идея / не лучшая практика?

3) Это сообщение об ошибке полностью выкидывает меня:

[master]. [Dbo]. [Fn_MoH_RightJustify] или [meta]. [Job_Status]. [Master] :: [dbo]. [Fn_MoH_RightJustify].

Что такое [мета]. [Job_Status]. [Master] :: [dbo]. [Fn_MoH_RightJustify] ??? В таблице Job_Status нет столбца [master].

4) Все определения схемы импортируются SSDT? Нужно ли создавать их вручную (некоторые из них)?

5) У баз данных DW много синонимов. SSDT правильно обрабатывает синонимы?

Спасибо ...

Edit: Причина, по которой SP находятся в master, заключается в том, что они нужны мне в контексте текущего соединения с базой данных Я попробовал отдельную базу данных Tools, но не смог заставить это работать. См http://sqlserverplanet.com/dba/making-a-procedure-available-in-all-databases.

Так как SP есть, я поместил UDF там, чтобы быть последовательным.

Я использую синонимы вместо трех имен уровней, то есть dbo.fn_MoH_CleanString вместо master.dbo.fn_MoH_CleanString.

И мне кажется, я начинаю "видеть" проблему. Когда я добавил ссылку на master, SSDT использовал статическую копию master в зависимости от настроенной версии SQL Server. Если я просматриваю файл .sqlproj в редакторе, я вижу:

<ItemGroup>
  <ArtifactReference Include="C:\Program Files (x86)\Microsoft Visual Studio\2017\SQL\Common7\IDE\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas\master.dacpac">
    <HintPath>$(DacPacRootPath)\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas\master.dacpac</HintPath>
    <SuppressMissingDependenciesErrors>True</SuppressMissingDependenciesErrors>
    <DatabaseVariableLiteralValue>master</DatabaseVariableLiteralValue>
  </ArtifactReference>
</ItemGroup>

Я думал, что ссылка на master привела к динамической проверке во время выполнения master.

Я не могу создать dacpac master из SSMS - недостаток SSMS - но могу из SSDT. Однако я получил эту ошибку:

/****** Operation Steps ******/
Step 'Extracting schema from database'. Progress: Pending
Step 'Resolving references in schema model'. Progress: Pending
Step 'Validating schema model'. Progress: Pending
Step 'Extracting schema'. Progress: Pending
Step 'Extracting schema'. Progress: Running
Step 'Extracting schema from database'. Progress: Running
Step 'Extracting schema from database'. Progress: Completed
Step 'Resolving references in schema model'. Progress: Running
Step 'Resolving references in schema model'. Progress: Completed
Step 'Validating schema model'. Progress: Running
Step 'Validating schema model'. Progress: Failed
Step 'Extracting schema'. Progress: Failed

/****** Logged Messages ******/
Extracting schema (Start)
Gathering error messages
Gathering cryptographic providers
Gathering credentials
Gathering logins
Gathering server roles
Gathering server role memberships
Gathering linked servers
Gathering linked server logins
Gathering routes
Gathering ddl triggers
Gathering encrypted and clr ddl triggers
Gathering event notifications
Gathering server audits
Gathering server audit specifications
Gathering event notifications
Gathering database options
Gathering users
Gathering roles
Gathering application roles
Gathering role memberships
Gathering filegroups
Gathering files
Gathering full-text catalogs
Gathering assemblies
Gathering certificates
Gathering asymmetric keys
Gathering symmetric keys
Gathering encrypted symmetric keys
Gathering database encryption keys
Gathering schemas
Gathering XML schema collections
Gathering user-defined data types
Gathering user-defined types
Gathering table types
Gathering unique keys for table types
Gathering primary keys for table types
Gathering check constraints for table types
Gathering default constraints for table types
Gathering partition functions
Gathering partition schemes
Gathering functions
Gathering encrypted functions
Gathering aggregates
Gathering procedures
Gathering procedures
Gathering encrypted procedures
Gathering encrypted procedures
Gathering encrypted procedures
Gathering tables
Gathering tables
Gathering primary keys
Gathering unique constraints
Gathering foreign keys
Gathering default constraints
Gathering check constraints
Gathering views
Gathering encrypted views
Gathering indexes
Gathering statistics
Gathering full-text index stoplists
Gathering search property lists
Gathering search properties
Gathering full-text indexes
Gathering column store indexes
Gathering spatial indexes
Gathering XML indexes
Gathering Selective XML indexes
Gathering encrypted triggers
Gathering triggers
Gathering encrypted and clr ddl triggers
Gathering ddl triggers
Gathering synonyms
Gathering defaults
Gathering data constraint uddt bindings
Gathering rules
Gathering data constraint uddt bindings
Gathering message types
Gathering queues
Gathering contracts
Gathering services
Gathering routes
Gathering event notifications
Gathering remote service bindings
Gathering broker priorities
Gathering database audit specifications
Gathering signatures
Gathering signatures
Gathering data compression options
Gathering sequence types
Gathering extended properties
Gathering extended properties
Gathering extended properties
Gathering extended properties
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] has an unresolved reference to object [SSISDB].[catalog].[packages].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] has an unresolved reference to object [SSISDB].[catalog].[projects].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[packages].[p], [SSISDB].[catalog].[packages].[project_id] or [SSISDB].[catalog].[projects].[p].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[packages].[j], [SSISDB].[catalog].[projects].[j] or [SSISDB].[catalog].[projects].[project_id].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] has an unresolved reference to object [SSISDB].[catalog].[folders].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[j], [SSISDB].[catalog].[packages].[j], [SSISDB].[catalog].[projects].[folder_id] or [SSISDB].[catalog].[projects].[j].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[f], [SSISDB].[catalog].[folders].[folder_id], [SSISDB].[catalog].[packages].[f] or [SSISDB].[catalog].[projects].[f].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[f], [SSISDB].[catalog].[folders].[name], [SSISDB].[catalog].[packages].[f] or [SSISDB].[catalog].[projects].[f].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[j], [SSISDB].[catalog].[packages].[j], [SSISDB].[catalog].[projects].[j] or [SSISDB].[catalog].[projects].[name].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[p], [SSISDB].[catalog].[packages].[name], [SSISDB].[catalog].[packages].[p] or [SSISDB].[catalog].[projects].[p].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[f], [SSISDB].[catalog].[folders].[name], [SSISDB].[catalog].[packages].[f] or [SSISDB].[catalog].[projects].[f].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[j], [SSISDB].[catalog].[packages].[j], [SSISDB].[catalog].[projects].[j] or [SSISDB].[catalog].[projects].[name].
Error validating element [dbo].[ssisprojects]: View: [dbo].[ssisprojects] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[p], [SSISDB].[catalog].[packages].[name], [SSISDB].[catalog].[packages].[p] or [SSISDB].[catalog].[projects].[p].
Error validating element [dbo].[ssisprojects].[Folder]: Computed Column: [dbo].[ssisprojects].[Folder] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[f], [SSISDB].[catalog].[folders].[name], [SSISDB].[catalog].[packages].[f] or [SSISDB].[catalog].[projects].[f].
Error validating element [dbo].[ssisprojects].[Project]: Computed Column: [dbo].[ssisprojects].[Project] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[j], [SSISDB].[catalog].[packages].[j], [SSISDB].[catalog].[projects].[j] or [SSISDB].[catalog].[projects].[name].
Error validating element [dbo].[ssisprojects].[Package]: Computed Column: [dbo].[ssisprojects].[Package] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [SSISDB].[catalog].[folders].[p], [SSISDB].[catalog].[packages].[name], [SSISDB].[catalog].[packages].[p] or [SSISDB].[catalog].[projects].[p].
Extracting schema (Failed)

Стоит ли просто отключить проверку dacpac при его создании?

...