Can I create a SQL database in Visual Studio Code for OS X? - sql

I have just downloaded Visual Studio Code (for OS X) and I wanted to try and create a simple REST API server to test out all possibilities. I can't seem to find how to create a SQL database.
Do I need to create one in another application? If so, how?

Visual Studio Code is not a fully featured IDE like Visual Studio. It does not support tasks such as creating databases or viewing them from within the App. If you want create a database, refer to the docs of the database provider for your target platform.
As for the REST API server, Visual Studio Code can be great help - specially if you are using ASP.Net 5 or node.

Related

Can't create a simple SQL Test

I'm trying to get just basic unit testing on an SQL database through a Visual Studio project.
The first thing I tried was just creating a simple .Net Core Unit Testing library.
Then I added an SQL Test, and it couldn't link to the SqlDatabaseTestClass`. Looking around, this is a fairly ubiquitous issue, but I found an obscure comment at the bottom of https://developercommunity.visualstudio.com/content/problem/29842/database-unit-test-project-does-not-build-in-visua.html that said that it's probably a linking issue.
So I created a .Net Framework Unit Test project. Now that has no option to add an SQL Test.
So I found an article that says that I should try creating an SQLDatabase https://www.codeguru.com/csharp/.net/net_data/create-sql-server-database-unit-tests-using-visual-studio.html
But then I got an error that The server version or database compatibility level is not supported. Import Database in VS 2015 SQL Server Database Project
The solution to that was to go to the SQL Server Object Explorer and right click on the DB and create an SQL project by right clicking on the Database. And that worked! Finally I have a project with database tables.
But now when I right click on a stored procedure, I don't get the option to create a unit test.
I figured it out.
Open the View -> SQL Object Explorer in the top menu bar in Visual Studio 2017. Make sure it's the Object Explorer and not the Server Explorer. These instructions presuppose that you have your connections setup properly.
Right-click on your database and click Create New Project. Make sure the directory is correct because it wasn't for me.
After the database imports, go to your Error List and resolve all those errors. Now you should be able to right-click on a stored procedure in either the SQL Server Object Explorer and select Create Unit Tests.
Allowing Visual Studio to do all the heavy lifting sorted me out.

Change database schema in published Lightswitch application

I have created a functioning LightSwitch (Visual studio 2012 Pro) application...
Now it's time to publish! The only problem is that I can't seem to figure out how to change the schema name to something other than dbo.
That is, I don't want the output tables to be dbo.XXXX, I want them to be my_schema.XXXX instead.
Also, note that the database is on SQL Server 2005.
Does anyone have suggestions on how to achieve this?
Thanks!
Update: Sorry for not being specific. I don't want to change the schema for existing tables in my database. I want my LightSwitch application to use the new schema. I don't mind publishing it and then modifying the schema on the tables, if I can then somehow also modify the LightSwitch application to use the new schema. But ideally, there would be a way to tell LightSwitch to use a different schema when it publishes.
For those who don't know what LightSwitch is, it is a Microsoft .Net Rapid Application Development tool for SilverLight business applications, and is built into Visual Studio 2012. My application is written in VB.Net
You can't change the schema name for an intrinsic database (the database that is created with LightSwitch). Maybe you'll be able to in V3, but you can't currently do it in V1 or V2. To achieve this, you'll have to create the database in something like SSMS (SQL Server Management Studio, then attach to it as an external data source.
Seeing as you've already done all the creating in LightSwitch, you could publish it as is, then attach to it as I mentioned above. I hope you don't have screens created, because unless you want to manually edit all of the lsml, you won't be able to use the attached database in any already created screens.
Any time you need to do something "out of the ordinary" with LightSwitch's database, you need to create it outside of LightSwitch, then attach to it. Why? LightSwitch was originally created with the idea in mind that the users didn't need to know anything about SQL Server.

Starting From Scratch - What SQL database should I use with Visual Studio?

I recently got a new primary computer. On my old one, I was working with MS Visual Studio 2008 (or maybe an older version - I can't remember now). I had managed to get SQLite working with it and was in the start/middle of building an application.
On the new computer, I now have MS Visual Studio 2010. I have had problems getting SQLite to work with it. Honestly, I haven't tried super hard yet, because I realized I pretty much want to completely redesign this application anyway and it got me thinking... do I really want to use SQLite or some other SQL? MS SQL (or is it called SQL Server)? MySQL?
My end goal is to have an application that can be installed by the user with one .msi file and the user should not have direct access to the database (although at this stage, that is a secondary concern).
It seems like MS SQL / SQL Server is the easiest since it's also an MS product.... Would love some opinions!
(along with the opinions, I'd also love to be pointed to current instructions... I'm a programmer, I'm not a "coding environment setup" person and have always struggled with this. All I want is to get in there and write my application!)
Thanks in advance!
-Adeena
PS... I'm currently working with C# and would prefer to stick with it, but could easily do this in C++ (I'm fluent in all the flavors of C) if that makes a difference with the database.
SQL Server would be a good choice by the sounds of what you're after. Try the express version - it's free, good for development and prototyping and integrates really well with Visual Studio.
The SQL Server Management Studio tool is excellent. I use this to create the databases I need and then use Visual Studio to manage them (saves switching windows and running both applications when you're working in VS all day anyway). I used to have my issues with the old Enterprise manager software but things really seems to have stepped up for SQL Server 2008 and the new management studio.
Like the title of your question suggests, you're wanting to use this with Visual Studio. If you decide to do use SQL Server then you should:
Download the express edition
Download SQL Server management studio
Create a database
In Visual Studio - click View -> Server explorer -> right click Data connections and add connection. Select MS SQL Express and choose localhost as your server. You can then select the database you created using the management studio.
There you have it - integration with VS.
You say you're using C#.Net - well SQL server and .Net go hand-in-hand. Obviously you can hook up to other third party databases but SQL was really made to work with this stuff. It's a powerful database engine and will do everything you'll ever need as well as being well supported by Microsoft and the wider community.
If your final goal is to have hands-off single-click installation then I don't think SQL Server Express is your best bet because it's not a file-based embedded database. It's a great db and very easy to work with, but when it comes to deployment still takes some installation effort. You could try one of: SQL Server Compact Edition, SQLite or Firebird Embedded.
SQLExpress is free and for development purposes is pretty much interchangeable with the full SQLServer
http://www.microsoft.com/express/Database/
SQL SERVER seems to be the logical one.

Visual Studio Database Project and SQL Server Management

I enjoy using SQL Server Management Studio for change and updating my database. Its easier, faster, and safer than writing changes myself.
I was looking into using some sort of version control for databases and read about using a SQL Server Database Project in Visual Studio 2010.
I scripted out an existing database and imported it into a new SQL Server Database Project. Now, from what I can tell, there is no GUI to edit the database; I can't add columns, change datatypes, or edit existing data without scripting it myself. For instance, in SQL Server Management Studio I can right click on a table-name and select "Design" and then add/edit columns, change datatypes, etc from there.
While Visual Studio's Database Projects has some features SQL Management Studio does not have I don't think I can live without a "table designer".
Is there a table designer built into VS's Database Project I'm just not seeing?
No, there's no table designer.
If you're starting to think about version controlling your database, you ought also to be thinking about writing actual SQL to implement your database objects. That's the route that the Database Projects force you down. If you can't write the SQL for your database changes, how are you going to be able to review and appreciate a diff between how a table was 6 months ago, and how it currently is in your project?
I've been using VS2008 Database Projects for about 10 months now for our version control. Every now and then I do still use the table designer, it is a quick and easy tool. I believe the majority of your question centers around workflow as this is what I found to be the most challenging part about development in a version controlled environment. I would recommend continuing to design your objects in Management Studio or however you're comfortable and then do a create script and import that script into your Database project. There are some quirks when doing this, you'll need to always script the create statement even if you're performing an alter in your environment. As well you'll need to remove any USE statements for your database as the context in which you're importing your scripts will always be in the project you're importing to.
We have found that a successful workflow for us to facilitate code deployment is to have a production branch which is branched to a Main (development branch) and then to test. All new development is done in Main and merged by changeset to each other environment as required.
You can import your scripts from your development environment by right clicking in the solution and clicking import scripts. I recommend that you check all the options to overwrite objects that exist, import extended properties and import permissions.
After changing your DB schema using SSMS's GUI tool, you can use Database project's Schema Compare tool to update your project files (set the source to be your database and target to be your project). This way you can keep using GUI tool to manage the schema and the database project will manage the versioning.
There is no visual table designer in Visual Studio 2010 Database Project. But, concerning version control for databases, there is a workaround - you can use SQL Server Management Studio together with Red Gate's SQL Source Control. It costs some money but definitely is worth it.

References/walkthroughs for maintaining database schemas with Visual Studio 2010?

I have Visual Studio 2010 Beta 2 and SQL Server 2008 installed. I'm working with a populated database and want to modify various column types. SQL Server Management Studio requires me to drop tables to do this, and get pretty finicky given my moderate level of knowledge of SQL Server.
However, I heard the new database project type supports changing the database schema to the desired format and it will handle creating and running all the scripts to implement the changes.
I've created a VS2010 database project using the existing database as the source, but so far haven't had much luck figuring out the appropriate method to make the changes without getting an error.
As a result, I'm looking for any reference info I can find on using VS2010's capabilities in this area. Any suggestions?
write scripts instead of using the gui. You can use alter table for instance to change a column. Never use a GUI of any kind to create a change to a database table.
Here's a walk through of the new VS2010 "Deploy-SQL" tab in the properties page of web application projects.