How to convert VS2010 SQL Server Unit test project to VS 2012? - sql-server

I have VS 2010 project with SQL Server unit tests. I need to convert them to VS2012. After much googling I found a msdn article which does not lay out the steps. The context menu on project does not contain anything related to project upgrade. After opening the project in 2012 you wont see your test sql unit test queries. If I open it in vs 2010 I see them. After opening the project in vs 2012 and if I create new sql unit test it will get pop-up box saying :
I have SSDTBI_VS21012 installed. Any idea how I go about converting my VS2010 project with SQL Server unit tests to VS2012?

I work on the product team, thanks for raising this. After a quick investigation, this looks like it is a regression introduced in the July release of SQL Server database tooling in Visual Studio. Could you please file a connect bug for this issue at https://connect.microsoft.com/SQLServer/feedback/CreateFeedback.aspx and use the category "Developer Tools(SSDT, BIDS, etc.)". We will treat this as high priority, and this is the best way to ensure it'll get tracked and you can see when it's fixed.
Unfortunately there is no workaround in the July/November releases as an overzealous check was added to avoid showing this option for all unit test projects, and we don't have an overrideable command. However, to unblock yourself you should be able to do one of two things:
Workaround #1 uninstall the database tooling components and install an earlier version instead. Here's how:
Go to Add/Remove Programs
Uninstall "Microsoft SQL Server Data Tools 2012", which is the overall installer, if present
Uninstall "Microsoft SQL Server Data Tools - enu" (if you have English installed).
You shouldn't have to uninstall "Microsoft SQL Server Data Tools Build Utilities - enu" if you're using July/November release as it's no longer relevant. However if you run into trouble, consider uninstalling this too.
Install the April release of SQL Server tooling for VS2012 instead. The SSDTSetup.exe file to do this is found at http://download.microsoft.com/download/0/D/F/0DF6C816-A7D5-4C17-8B10-2061FC97D37E/EN/SSDTSetup.exe. Note if you are not using English, change the "/EN/" part of the URL to a different language such as DEU and it should allow you to download that language version.
Workaround #2 Migrate to a new Unit Test Project
You can alternatively create a new SQL Unit Test Project and migrate your tests across:
Create a unit test project based on a procedure in your SQL Project, or create a new Unit Test Project and go to "Add -> New Item -> SQL Server -> SQL Server Unit Test").
When it opens the SQL Server Test Configuration dialog, be sure to enter valid values for the reference project and the connection string(s) - these should match your previous project
Copy across your unit test files from the old project. If you build, it will fail due to a missing reference. We'll fix that next.
Unload the project (right-click, unload project) and add the following snippet near the top:
<PropertyGroup>
<IncludeSsdtUnitTestAdapter>True</IncludeSsdtUnitTestAdapter>
</PropertyGroup>
Reload the project, and build. This should now pass as the adapter DLL used in migration will be included in the references.
Lastly, run the tests and it should work.

Related

How to create a targeted dacpac without complications for ASP.NET Core web app and SQL Server database?

My yaml github workflow deployment build fails for actions/setup-dotnet#v1 looking for an unloaded SQL Server project. I don't understand why the build machine expects a SQL Server project file. I "Unloaded" the SQL Server project from my Visual Studio solution after creating the dacpac and before pushing. The same solution (now only .NET Core project with the unloaded SQL Server project) builds on my machine. The only reason I created the SQL Server project was for the dacpac.
C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0.400\NuGet.targets(290,5): error MSB3202: The project file "D:\a\rollbase\Database-Proj\Database-Proj.sqlproj" was not found. [D:\a\rollbase\rollbase\rollbase.sln]
Build FAILED.
Deleting the sql project to produce single proj solution builds successfully on github. So somewhere a reference to the unloaded project exists if it remains visible in VS Solution Explorer. Meaning the only way I can get the runner to build my solution is to delete the sql project after producing the dacpac each time. This seems clumsy and still leaves me not understanding the error.
This fairly recent post Developer Community Issue 2020 seems to indicate the same kind of problem but opposite fail situation. Though it doesn't help to only be able to read one half of the conversation.
Has anyone got a solution for my github DOTNET_VERSION: '5.0.400 build or a better process for getting a targeted dacpac during database updates for a net core solution? I would appreciate any input.

Can't open properly a SSIS package based job from SSMS in Visual Studio

I need to understand what a certain job in SQL Server 2012 does. It's a job someone created and left the company before I started to work here, and nobody on my team knows what this job does also.
The job isn't SQL command based but SSIS Package (which I'm not familiar with), the package points to a Maintenance Plan with the same name as the job. As I read on the internet I connected via Integration Services type, then Stored Packages -> MSDB -> Maintenance Plans, right click on the Maintenance Plan and exported it to a .dtsx file.
I opened it in Visual Studio 2010 Shell, but I can't edit anything because of this error:
The task with the name "" and the creation name "" is not registered for use on this computer.
I also don't have a Solution Explorer for that package, and the icons of the tasks seem a bit faded compared to tasks icons of a new project if I create one.
Maybe the dated version of the VS can be the problem? Perhaps there is other way to see what this job does?
I never worked with SSIS before so maybe I'm missing something very basic but I've been on the Internet for days already and can't find any solution.
Please help,
Thanks in advance
By way of background, until Visual Studio 2019, VS, by itself, couldn't open an SSIS package.
Prior to VS 2010, you needed to use a different product, called Business Intelligence Design Studio (BIDS), which was based on VS, but was built for SQL Server functionality. With the release of SQL Server 2012, Microsoft created SQL Server Data Tools (SSDT) as a plugin for VS that required a separate installation. Until SSDT(VS) 2017, you needed to have stand-alone versions of BIDS or SSDT for each version of SSIS you were working with in your environment. The 2017 version, though, is backward compatible to SQL Server 2012, and forward compatible (!) to SQL Server 2019. Visual Studio 2019 has SQL Server Data Tools sort of built in, but you need to add extensions through the extension manager for SQL Server Integration Services (SSIS), Analysis Services (SSAS), and/or Reporting Services (SSRS).
That's kind of a lot to take in, and is sort of irrelevant to you, but it forms the context for Larnu's comments. Rather than messing around with antique versions of Visual Studio, you should just install either VS2017 and also SSDT, or VS2019 with the SSIS extension. Both are in current widespread use, so support is easy to find, and either will allow you to work with the 2012 package you're trying to open up.
Once you have the software installed, you should be able to create a "dummy" integration services solution that you can use to open random packages. I keep one around called MiscSolution. Right click on the solution name, select Add -> Existing Item. Then find your .dtsx package and import it. (Or right click SSIS Packages -> Add Existing Package. I always do it at the Solution level because that interface allows you to select multiple packages.)
Note that when you do this, you're making a new copy of the package in your local solution directory. You are NOT working on the copy of the package that sits in the folder where you picked it up. This matters if you're going to be making any changes, since it will need to be redeployed. It also matters if you accidentally hose up the package, because you've done no harm as long as you just delete that copy.
Once the package imports, which might take a minute or so depending on how complex it is, you should be able to open it up and see what's going on.

visual studio 2012 SQL CLR

I am trying to create, test and deploy a SQL CLR (database project) using Visual Studio 2012 (update 2) and it is getting very frustrating.
The coding itself was trivial but now I cannot deploy or execute unit tests on the project. I have developed SQL CLR in VS 2010 and it was much simpler (Test.sql).
So here are my questions:
How does one set up a local SQL script to test the newly minted functions/sprocs? [I have tried adding a .sql file and marking it to be run on debug but I get error SQL71006.]
How does one deploy the project? I am deploying to SQL 2008 R2 and I know I need to use .NET 2.0 but I still have not been able to deploy anything. When I execute the generated .SQL on the target SQL Server instance, nothing happens (no errors, nothing).
This has worked so well with previous versions of Visual Studio one wonders if MSFT is perhaps now trying to discourage the generation of SQL CLR modules?
For first point, ensure that .sql file in properties has anything then Build in field Action
For second point, try to use a Publish option, where you will get a dialog box to set up database connection and other config option.
Deploy option does nothing when you work with database projects.

Setup and Deployement in VB.Net having Sql Server Database in the Project

I have completed my Project in VB.Net and has published my project.
But i want to come out of these things
I have Sql Server Database in my project and i want my setup to add that database to sql server on installing my project.
I want my application to automatically detect sql server 2008 r2 and if it is not instaled i want it to install for me and then atach the database.
I dont want to add the database as a Attached database in my project.
i dont want to install crystal report in my application.
I have some unused refernces in my application in my project which i want to removed, i have tried the default visual studio remove unused references but still have some references like shockwave.dll log2net.dll etc.
The first step would be to switch to an MSI-based installer. This should allow you to resolve issues 3 and 5 (you control what the MSI includes). You can use a Visual Studio setup project, WiX or a commercial setup authoring tool.
For installing your database (issue 1), the best approach depends on how you use your database. Some installers simply copy the database files, others install it using custom actions and others execute SQL scripts. You should first determine how you want to install it and then ask a more specific question if you encounter problems.
To install SQL Server when it's not found (issue 2), you can use a prerequisite. This is done differently for each setup tool, so you first need to decide on a tool and then research how it supports prerequisites.
For issue 4, I'm not sure I know what to say. An MSI package will install what you include in it. If you don't add Crystal Reports in your package, then it won't be installed.
Visit
http://www.codeproject.com/Articles/10032/Deploy-SQL-Server-databases-easily-with-an-Install
Deploy SQL Server databases easily with an Installer class
Best regards!
Elias Sant Anna

Embedding SQL Server into a .NET application

Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone?
You can do a rightmouse on the properties of your Visual Studio Setup Project, and then there is this button 'Prerequisites'. There you can tick 'SQL Server Express ...' Or the 'SQL Server Compact 3.5'
link to image
You're probably best off just to set the connection file directly to the mdf, and attach it when the program is run. This is easier as it doesn't require a custom setup script to install the database to the database directory itself.
Note: Consider using the Compact Version, it's smaller, people don't like a full blown engine on their computer :)
InstallShield has a concept called Setup Prerequisites where you can teach it how to install additional packages along with your own. In older versions this would happen before calling your MSI. In newer versions you can have a "Feature" prerequisite where the prereq can associated to a feature and only installed if that feature is selected to be installed and after it's been selected but still before the main activity of your MSI occurs during the install execute sequence.
InstallShield also has a pattern for executing SQL scripts against your database instance so that you can then load your database into your newly installed instance.
All of this is quite powerful but it does take a bit of digging to learn.
As far as I know, anything but the SQL Server Compact Edition (SQL Server CE) cannot be embedded into your setup, really. Microsoft doesn't want that - you need to have SQL Server Express installed separately - any other edition can't even be shipped with your software (the client must have a license and installation separately).
You can indeed distribute SQL server with your custom application:
http://msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx

Resources