Publish to Azure SQL from Visual Studio 2017 - Unable to connect - visual-studio

I recently set up an Azure SQL Database and server (using the free S0 trial). I've been able to log in to it using SQL Server Management Studio and create a couple users, and I've been able to log in as those users through SQL Server Management Studio. I'm also able to log in and manage the database from Visual Studio's Server Manager and SQL Server Object Explorer.
I have a SQL Database Project in my Visual Studio Solution for an app I'm working on. Using the same connection strings that I've been using in SSMS and VS's server manager, the Database Project is unable to publish to Azure, throwing the following error:
Unable to connect to master or target server '{Redacted}'.
You must have a user with the same password in master or target server '{Redacted}'.
My IP has been added to the firewall and is set to allow access. My username does not include the # sign, and I have tried with and without the #servername with no change. I also tried manually setting up the connection string, and copying/pasting the one in Azure (and populating the username and password).
I currently have the database project's Target Platform set to Microsoft Azure SQL Database V12, which matches what it reports the version as, although I have tried just Microsoft Azure SQL Database and SQL Server 2016.
Seeing as I'm able to connect from every other method I've tried so far, I assume there's something wonky in my publish profile or project that just doesn't stand out to me, or a bug in the publishing utility. Any ideas?

This is a known issue. This happens due to the new compatibility level 140 for newly created SQL Azure databases. The issue has been documented here and updating SSDT from here to the latest version may solve the issue.
Alternatively, you can change the compatibility level of your database to 130.
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = 130;
Hope this helps.

Related

VS 2013 Setup Projects Works on one server and does not on another

We recently migrated from VS 2008 to VS 2013 including a set of setup projects. One of the setup projects is meant to install a web application. It has one custom action that is meant to check the connection to the database. The code of the custom action has not been touched during the migration and the .msi works perfectly when generated from VS 2008. When I built the .msi from VS 2013 it works perfectly well when installing on our local development server, and throw an error saying that it cannot connect to the db when rolling out in the clients environment.
I'd really appreciate if anyone can point me into direction of search here. I know that I'm passing a correct connection string, and .msi generated from VS 2008 can connect to that db from the same server.
Visual Studio custom actions that are installed for Everyone will run with the local system account. Connecting to a SQL DB will often fail because the DB doesn't allow the system account to connect, or because the DB is on a network share and the system account has no network privileges.
So it could fail because of the security settings of the DB or because the DB is on a network, and it may be nothing to do with the server. It might also connect if the install runs with a Just me setting because the custom actions then will run with the installing user's credentials. There may also be issues with architecture because servers are 64-bit and the 32-bit subsystem is optional, and you didn't say whether you install was x64 or your custom action code.

Can access SQL Database via SSMS, but not via VS2013

I have an Azure database, SSMS 2012, and VS 2013. I have created the appropriate logins and users for myself and a colleague using the server login to access the Azure database. However, for reasons unknown to me, I can only access the database through SSMS. In VS I can access and login into the server just fine. But, when we click to expand the database, it produces and 'x' and denies showing any related tables, etc. Yet, from SSMS all is accessible with no problem. My colleague can access the database on his machine via SSMS or VS 2013 Community Edition. The problem seems to exist on only my machine and only with respect to the created logins. I can access the database fine using the admin credentials. I have attempted reinstalling VS, but it hasn't helped. Thoughts from anyone?
To Access Azure on your system with VS 2013
Very first please allow your IP in Azure SQL database firewall.
Connect Azure Subscription in Server explorer.
Go to SQL database and select your database and right click on that and select "Open in SQL Server Object explorer".
In SQL Server Object explorer your database will reopen with all required option and table list.
It turns out I cannot access the database because the Azure db I created is the 2014 (v12) version. I have SSMS 2012 (v11) loaded on my machine which is not compatible with the v12 db. Hence, the issues. The short of it is: I need to update to SSMS 2014 and reload VS afterwards since it partially relies on SSMS.

TFS Build Unit Test with Oracle Instant Client

I am running TFS 2013 Update 2 on Windows 2008 R2.
I installed the Oracle Instant client 32 and 64. I've tried it with both clients 32/64 and changed the test run mode from x86 to x64.
--Update - I am using Tnsnames.ora and the user\schema and passwords are embedded in the config files. I don't think this is a user or password issue.
--Update - 2
I ran another test. If I delete the oracle folder the Build changes the error to:Oracle client software version 8.1.7 or greater. So the build controller is finding the oracle client. But it's not reading the tns.ora?? It's in the same folder.
I followed these instructions to add the tnsnames.ora as a registry key entry
How can Instant Client on Windows use registry settings?
HKEY_LOCAL_MACHINE\SOFTWARE for a global setting
2. Add ORACLE group key.
3. Add a new string value within the ORACLE key for the different settings you are interested in (NLS_LANG, TNS_ADMIN, etc.)
I rebooted and it still does does not run in the build.
I am running some basic CRUD Oracle test to validate the SPs in our applications.
On the build server we have Visual Studio and it will run the Unit test without issues. That tells me the Oracle client is working fine.
When I run the TFS build and the Unit test, I get the below error:
System.Data.OracleClient.OracleException: ORA-12154: TNS:could not
resolve the connect identifier specified
------Resolved----------
I had to change the permissions on the folder to let the service account have admin access.
The username that is running the build doesn't resolve the Oracle database name. Connect on the build agent with that user and try to do a tnsping.

Can't add Local Database to project

This might be a really dumb question... but in VS2013 when trying to add a local database to my Windows Forms Application Project the option is now shown in the C# items menu. The only DB that is available is a Service-Based DB. From what I understand, this is related to SQL Compact Edition but I do have SQL Server 2012 installed. Any ideas? Or are there any significant differences between the Local DB and Service-Based DB?
A service-based database is a database that is only accessed through a server. It uses an MDF data file, which is SQL Server format. To be able to connect to a SQL Server database the SQL Server service must be running, because it's that that processes your requests and access the data file.
A local database is one that is local to your application only. It uses an SDF data file, which is SQL Server CE (Compact Edition) format. There is no need to install a server to access an SDF database. You simply distribute the DLLs that constitute SSCE along with your app and access the data file directly.
You'd normally only use SSCE if the data was to be accessed by your app only and there was a relatively small amount of data. For your project you would use SQL Server. For testing purposes you can use the free Express Edition. When deployed you might still use SSEE or you might use a full version of SQL Server. Note that Microsoft include SSEE with their own RMS POS software. SSEE is limited to databases of 4GB though, so even if you start out with SSEE and it can handle the load, you may still have to upgrade at some point in the future based on data capacity.
Source of info:jmcilhinney post.
for help on creating the database have a look at this tutorial it may be of some help.
Hope this info helps you :)
It turns out VS2013 dropped the .sdf format.
Is Microsoft dropping support for SDF database files in Visual Studio?
The answer is yes: Microsoft is silently dropping support (as usual IMHO) to Sql Compact Edition.
It started abandoning Sql CE 3.5 in Vs2012 It continued dropping Sql CE in Sql Management Studio 2012 and finally in VS2013
You can use CompactView or install SQL Server Compact Toolbox extension in VS2013 or (my prefered solution) use Sql management Studio 2008
UPDATE thanks to Nicolas' comment
As stated by Microsoft:
SQL Server compact edition is in deprecation mode with no new releases planned near future. Last release SQL CE 4.0SP1 (and earlier releases that are still in the support cycle) will continue to be supported through its lifecycle and Microsoft is committed to fix any major, production blocking issues found in these releases.
Have you tried adding your local database from inside the project? Have a look and see if you can add your database from datasources.

Oracle Data Access Components and Visual Studio connection problems

I've created an empty console application in Visual Studio 2010 and I'm attempting to add an Oracle (10g XE ) Data Connection via the Server Explorer. I'm using Oracle ODP .NET as the connector and I get the following error:
ORA-12560: TNS: Protocol Adapter Error
I can access Oracle without issue via the web interface or a console, but continually get this generic connection error in VS. I'm using the default installation of Oracle XE and running it locally.
Any suggestion on how to get this set up correctly ? Every tutorial I find works on the understanding that this connection succeeds. As such I'm struggling to find where to begin to troubleshoot. I'm comfortable with VS2010, but new to the way Oracle does things with their DB.
EDIT 1
While troubleshooting I've found this only happens with the Oracle Data Provider for .NET. Using the .NET Framework Data Provider for Oracle I am able to successfully connect.
EDIT 2
I cleaned up everything and installed 11g XE and the ODAC tools again and continue to get the same message. I realize the error is somewhat generic, I'd be happy to post more information if anyone thinks it helpful. The database is run locally, I can't imagine what kind of 'configuration' an express database would even need...
EDIT 3
The ODAC tools appear to install a 'production' version of Oracle 11 instead of the BETA version that I installed first. Almost appears as if the tool is installing another database ? I also appear to have two ORACLE_BASE locations and two TNSNAMES in what appear to be very similar folder hierarchies. Perhaps a more straightforward tutorial is the answer, Oracle's isn't very descriptive.
Oracle 10g XE seemed to be the problem. A full install of 11g (Full, not Express) took care of the problem entirely.
From here:
Possible fixes for the TNS-12560
include:
Get the latest patches for the SQL*Net client software.
Check your $ORACLE_HOME and $Path variables.
Check File permissions on the PC client.
Ensure that TNS_ADMIN is set correctly.
Check for firewall issues.
Check that the Windows database service is started. Verify teh
ORACLE_SID parameter is set correctly
in the registry.
Wow. I finally got this syntax to work.
I'm a Sql Server guy. I used Oracle back in the da day.
But I'm trying to do some Entity Framework and I said "You're not going to bed until you get Visual Studio 2012 and a edmx file to talk to Oracle.
Geeze.
Here is what I came up with:
Data Source:
Oracle Database (Oracle ODP.NET)
Data Source Name:
localhost:1521/orcl
User Name:
SYSTEM
change the default data source name to localhost.

Resources