Working with Tables and Indexes in Rider
In previous blog posts in this series, we looked at connecting to a Microsoft SQL Server and getting familiar with the features in Rider to work with SQL databases. In this blog post, we will look at how to work with a database to create tables and indexes.
This post is part of a series around working with databases and data in Rider:
- Configuring SQL Server 2017 for Rider
- Getting started with database support in Rider
- Working with Tables and Indexes in Rider
- Working with Data in Rider
(Note: we’ll use the Visual Studio keymap on Windows throughout this post – check the web help for Mac OS X and other keyboard schemes)
Creating/Modifying a Table
To create or work with existing tables in your database, you will need to open the View | Tools Windows | Database menu selection to view the details of your database or use Ctrl+T or a double Shift and then type “database” to get the window.
Expand the tables view in the Database window and right click to create a new table.
The Create New Table dialog will be presented to work in the new table.
You can create the columns, keys (including primary), indices and foreign keys by using the tabs and commands on the right border. The Action of the dialog with either allows the table to be immediately created in the connected database or to return the SQL script for the created table back in the Database Console. To finally create the table, execute the SQL script in the console.
Working with an existing table is through right-clicking the table in the Database windows or use the Ctrl+F6 keyboard shortcut.
In the Modify Table dialog, to edit a column double-click the row.
After changing the table, you can either immediately update the table or save the script back to the Database Console just like when creating a new table.
Deleting a Table
Deleting or dropping a table from your database is performed by right-clicking the table and performing the Drop command or pressing the Delete key.
Working with Primary and Foreign Keys
The column that identifies your primary key in your table is set up through the Modify or Create New Table dialogs. Checking the Primary key checkbox and then executing will identify the column as the unique key for the table.
Working with foreign keys is also performed through the Modify or Create New dialogs. The list of foreign keys is on the Foreign Keys tab. Creating a new one through the Add command or Ctrl+N.
You are then able to create the name of foreign key, identify the target table, choose your update and delete rule types and finally, the keys to join in the target table from the table.
Working with Indexes
Working with Indexes or Indices of a table is performed in Indices tabs. Notice that there could be an index if you have created a primary key in the table. Create a new index using the Add command or Ctrl+N.
After creating a new index, you can update the name, the uniqueness and the column(s) with sorting on each column in the index.
Generating a Database Diagram
To view the Database Diagram while you are working with your database, perform the keyboard shortcut Ctrl+Alt+U.
Rider has a very rich and powerful set of data features that we have reviewed in this third part of the series. In our next post, we will look at how to use Rider to work with the data inside your tables, and other advanced topics.
Download Rider 2017.3 and give it a go! We’d love to hear your feedback!
Subscribe to Blog updates
Thanks, we've got you!
Visualize Entity Framework Relationships and Additional Query Analysis in ReSharper 2023.3
A lot of teams are using Entity Framework or EF Core to work with their database. As an Object-Relational Mapper (ORM), it bridges objects in code to a relational database model, so that as a developer you don’t have to worry too much about the actual database. We all know: that’s not entirely tr…
Automatically Analyze ASP.NET Core Performance With Dynamic Program Analysis
Slow web pages may make your users or customers abandon your web application, even before they’ve had a proper look at it. You’ve likely also been frustrated working with a web application that is slow to load. The good news is that the latest versions of ReSharper and JetBrains Rider’s Dynamic P…
OSS Power-Ups: MassTransit – Webinar Recording
The recording of our webinar, OSS Power-Ups: MassTransit, with Chris Patterson, is available. This was the thirteenth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webinars.…
Eager, Lazy and Explicit Loading with Entity Framework Core
Entity Framework Core (EF Core) supports a number of ways to load related data. There’s eager loading, lazy loading, and explicit loading. Each of these approaches have their own advantages and drawbacks. In this post, let’s have a quick look at each of these ways to load data for navigational prope…