how to connect SQL Server .ndf file to visual studio 2013? - visual-studio-2013

I am using SQL Server 2014 and Microsoft Visual Studio 2013 and want to connect my .ndf file with Visual Studio 2013.
Is It Possible?

It doesn't. For starters, you connect to a database that is hosted by an instance of a SQL Server engine. There is no concept of connecting directly to a data file, primary (mdf) or otherwise (ndf, ?df). You also cannot connect directly to an ndf file without the primary (mdf) file. Metadata about the database (including files and locations) along database objects are stored in the mdf so without that, you can't even start your database.

Related

How do I connect Azure SQL to Visual Studio?

I’m doing a project for school that requires building a function IT project. I’ve got the HTML, CSS, and SQL parts down pat. It’s the combination in Visual Studio 19 Mac that isn’t clicking for me.
How do I go about connecting my existing SQL database to my Visual Studio project?
Check out https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-content-reference-guide. This reference guide will point out how to obtain the connection string for your Azure SQL Database. You can use this connection string to add a connection via the SQL Server Object Explorer, (Ctrl+, Ctrl+S) in Windows, I assume it's (Cmd+, Cmd+S) on Mac, to be able to query your database from inside Visual Studio.
The Add Connection diaglog will allow you to add your IP to the Firewall which is needed to access the database/server. This principal works the same for local network databases. Make sure you choose the correct Authentication type, e.g. Azure AD for Azure SDL, Windows for local network SQL Servers if so properly configured. You can always use SQL Server Auth for either one.

Generate Code Map For Solution - Unable to Connect to the Specified Database

I am attempting to generate a code map using Visual Studio 2017 Enterprise, but receive the following error:
Note the data source: Data Source=(LocalDB)\MSSQLLocalDB. When I search for MSSQLLocalDB in my solution, nothing comes up. My application does not use SQL Server 2016 (which is what I think the connection string is for). It uses 2012. All my connection strings use (localdb)\v11.0.
Fixes I've attempted / notes:
I have tried to view the XML file, but "Open the XML Editor" simply closes the .dgml file in Visual Studio.
Changing Visual Studio's data connection (Tools -> Options -> Database Tools -> Data Connections) does not work:
Installing SQL server components. Most of the SQL Server components one might find in the Visual Studio Installer are already installed:
Visual Studio is up to date:
I have seen this issue. Not only is that problem for VS2012, the solutions are for web.config. My app is a desktop app, so no web.config. But none of the projects' app.config contain a reference to (LocalDB)\MSSQLLocalDB anyway.
Thinking that it might have to do with the latest version of SSDT (15.8.1) no longer supporting SQL Server 2012, I checked the version. It is 15.1.6:
Visual Studio is running on Windows 7 Ultimate, SP1, 64-bit.
EDITS
I am using SQL Server express with Local DB.
The issue does not appear to be related to connection strings. Following basic instructions for creating an SSDT project (here), and importing the database (noting that in step 6 I target SQL Server 2012), the issue still remains - no connection strings, and no actual code.
I have also verified that SQL Server 2012 is the only connected server:
Error message added for SEO purpose (the question was not findable on search engines)
The XML content in this document cannot be viewed as a graph because it contains unexpected errors. Open the XML Editor to fix these errors and then try re-opening the graph. The actual error found is described below. Unable to connect to the specified database. An exception occurred attempting to connect to a database using the following connection string : Data Source=(LocalDB)\MSSQLLocalDB : Attach DbFilename=;Initial Catalog=master Integrated Security=True;Enlist=False;Asynchronous Processing=True; MultipleActive ResultSets=True Connect Timeout=30. Check that the specified SQL Server instance exists and the service is running. Call Stack : at Microsoft.Repository.SqlInteraction. OpenAndConfigureConnection (SqlConnection connection) Microsoft.Repository.SqlInteraction.<>c__DisplayClass7_0.<UsingConnection>b_0 () at at Microsoft.Repository.SqlInteraction.ExecuteRepositoryAction (Action action) at Microsoft.Repository.SqlInteraction. UsingConnection (SqlConnection sqlConnection, Action`1 act) at Microsoft.Repository.SqlInteraction. UsingMasterConnection (String connectionString, Action`1 act) at Microsoft. Repository. Utilities.GetDbStateAndFileNames (SqlConnectionStringBuilder builder) at Microsoft.Repository. Utilities.GetDatabase State (String connectionString) at Microsoft.VisualStudio. Architecture Tools. Progressive Reveal. PRUtilities. CanQuery (ActionContext context, IProgressionCacheSettings settings) at Microsoft.VisualStudio. ArchitectureTools. Progressive Reveal.GetRepositoryTimestamps Command.Execute (ActionContext context, IGraphStatus status Reporter, IProgressionCacheSettings settings) at Microsoft.VisualStudio. Architecture Tools. ProgressiveReveal. Progressive RevealProvider. GetRepositoryTimestampsHandler (ActionContext context) at Microsoft.VisualStudio. Progression. ActionManager. CallNormalActions (Action action, ActionContext actionContext, Boolean propagateCancellation)
I had the same issue with VS 2019. My solution was to delete and recreate the database MSSQLLocalDB. The cause was probably that my account didn't have rights to open the DB, maybe because my admin installed Visual Studio with his account.
Here the steps to recreate the DB:
Locate the location of the SQL Server LocalDB utility.
For me this is "C:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe".
Open an admin shell in that folder.
SqlLocalDB.exe i shows all database instances.
Delete the DB: SqlLocalDB.exe d MSSQLLocalDB
If this fails, you may need to try SqlLocalDB.exe stop MSSQLLocalDB -k first.
Recreate the DB: SqlLocalDB.exe c MSSQLLocalDB
Now I can use VS code maps and I can open the DB in the SQL Server Object Explorer in VS.
For me the solution was to delete folder c:\Users\u1\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\ (stop 'sqlservr.exe' that locks this folder) - and it will be re-created (answer). Looks like this folder (or some file in it) was created by elevated process and neither VS nor sqllocaldb.exe can access it.

Advice on creating a local instance of Azure Website

I have, I admit, done things the wrong way round and created an Umbraco installation on Azure, developed multiple websites on that installation and only just decided I want a local instance for further development purposes.
Given that that's where I am, does anyone have any advice for how to go about achieving this? I have tried installing Visual Studio Community 2017 and MS SQL Server 2017 Developer and while I can connect to Azure with Visual Studio I don't seem to be able to work out how to view the installation, much less copy it down to my PC (something which I my searches seem to suggest isn't possible with Visual Studio).
I think you will need to copy down the site via FTP and the database using SQL Server Management Tools (assuming you are using SQL Server and not SQL CE).
You can get the FTP connection information from the Azure portal. The web root is in /site/wwwroot. Copy it down locally and you will be able to open it in Visual Studio as a Web Site. For the database, you can connect to the Azure SQL database with SQL Server Management Tools (you should have the connection info from when you created the database) and then right click on the database, select "Tasks" > "Export Data-tier application..." which will allow you to save a 'bacpac' file your local machine. You can then connect to your local SQL Server instance, and then right click on the "Databases" node in the Object Explorer and select "Import Data-tier application..." Once the database is imported, you may need to create/update a SQL Server user and grant it access to the database you just imported. For local development I just set the user to be owner of the the db. Back in Visual Studio, you should update the "umbracoDbDSN" connection string to use the new local database. At this point you should be able to run the website locally.

Can't find local SQL database from within Visual Studio in my ASP .NET MVC 4 project

I have a project that uses EF 5 (code first) in Visual Studio 2012. When I build the database it works, but it isn't showing up in the SQL Explorer for some reason. I checked the connection object at runtime and I can see that the name of the local database is not listed in the SQL explorer. What's odd is that this project doesn't have this problem on another machine. The project is under source control
Check to see if you have a running copy of Sql Server running.
I experienced the same thing; creating a project and then EntityFramework objects, and then running the project. VS 2012 created the database in my 2008 R2 db which was running at the time, but I hadn't opened it in VS, so didn't see the new db. It wasn't until I specifically opened that db in VS that it appeared.

Visual Studio Project that execute an SQL script

I have this question... probably is similar to Executing scripts from a database project in visual studio
but i didn't understand the solution given.
So i made a Database Server 2008 project inside visual studio.
Just one table. When i press DEPLOY the database is created inside SQLServer2008 and the table is created.
Now what if i would like to give the project to someone who has SQLServer and he needs to recreate the database and the table in his computer?..
Apart form executing the query from Visual Studio is there any way to create an executable that automatically "deploy" from outside Visual Studio?..
Thanks,
There are different types of Database projects in Visual Studio. The old ones, which were not so feature rich. The 'Data Dude' ones that came with Visual Studio 2010 Team Database Edition and the most recent iteration that comes with the SQL Server Data Tools. All of these can be installed on top of the standard Visual Studio Professional and don't require additional licenses.
SQL Server Data Tools is the latest, and also the best integrated and most powerful variant of the bunch. It can also be used to compare existing schema's and generate upgrade scripts or automatically upgrade the schema in an existing database for you.
During build, a package will be created that holds all the schema information for your database. You can then use the command line tools provided by the SQL Server data tools or MSDeploy to deploy your compressed schema file to a new or an existing database.
This deployment mechanism can also upgrade existing schema if needed.

Resources