Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Tuesday, June 2, 2020 12:45 PM | 1 vote
Hi there,
I am trying to build a SQL project in VS. There is a view with references to the sys.syslanguages. This gives an error i cant solve...
I added master to my references. But still i get the error SQL71561: unresolved reference to object
Weirdest to me is that it is only for the columns:
[dateformat]
[name]
[alias]
[months]
[shortmonths]
[days]
So i gather that the dacpac of the master is missing some columns.
How To solve this error?
Thanks for the help.
Code that generates the error:
SELECT [langid]
,[dateformat]
,[datefirst]
,[upgrade]
,[name]
,[alias]
,[months]
,[shortmonths]
,[days]
,[lcid]
,[msglangid]
FROM master.sys.[syslanguages]
EDIT: The actual code i used in the project is different from the code above. The code above was just a test to see where the error came from. I was dumbfounded when some colums did produce errors and some columns didnt. In the end it seems VS is just buggy when referencing master database.
Wednesday, June 3, 2020 7:41 AM ✅Answered
"You cannot reference master objects in Azure, so this is expected."
If this is expected behaviour, can you please clarify:
1) why i can add the master as a reference in VS when selecting 'Microsoft Azure SQL database'. I am not on azure when doing this, still on my local machine, selecting a local reference to master.dacpac in VS.
2) why changing back to version SQL2016 may/ or may not resolve the errors?
Of course, today, when changing back it does work..
**For now i am concluding that VS is buggy when referencing master databases. Changes may or may not be visible right away. Or even worse, deleted references may re-appear after re-opening a solution. **
Be carefull !!
How to add master references in VS:
Add a database reference to master
3) And maybe explain how to change the project as to ignore these errors (in the right way) when deploying to azure?
EDIT:
To solve these errors one can either create the tables inside the database or create a connection through external tables as shown here:
Querying Master Database DMVs in Azure SQL Database
Tuesday, June 2, 2020 5:26 PM
I am not able to repro. Please share your .sqlproj file.
Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com
Tuesday, June 2, 2020 7:31 PM
I tried to reproduce on a smaller project so i can easily share the project file.
But lo and behold the problem doesn't exist in this new project, though i was sure this afternoon it did.
Maybe my original project is corrupt somehow. Let you know my findings.
Tuesday, June 2, 2020 7:42 PM
Not sure what fixed it, but problem fixed.
As the dutch would say "Nu breekt mijn klomp".
The original project suddenly is working as expected. I don't know what fixed it, i reloaded the project a few times. Even created a new branche and switched a few times from master to new branche. In the new branche i deleted all the stuff not needed for reproducing this error. Then switching back to master branche (the original where the error started)...it works.
I did notice a few times that there suddenly appeared multiple 'masters' in my reference list with a yellow maker in the original project. I deleted those multiple times, they had a habit of returning. Then suddenly the original version of the project is working as expected, there is only one master in my reference and the errors are gone.
Build is successful.
Problem is solved, reason yet unclear.
Tuesday, June 2, 2020 9:02 PM
Well at least I know how to create the errors. I changed the smaller project to SQL version 'Microsoft Azure SQL database' and changed also the 'master' reference to reflect this change.
(new master at: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\Extensions\SqlServer\AzureV12\SqlSchemas\master.dacpac)
This (re)created the errors. So not sure why they start or exactly how to solve them. Also switching back to SQL 2016 didn't fix the errors.
Some further testing seems to point in the direction that somehow VS (at least mine does) has a problem with adding the (new) master as a reference after the SQL version is changed.
Projectfile is here.
https://github.com/dewitweb/errorSQL71561
Wednesday, June 3, 2020 6:04 AM
You cannot reference master objects in Azure, so this is expected
Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com