How to use a Database project in .NET Visual Studio?

Introduction

The Database plays a vital role in any web or windows application development. The Database project can be used to maintain the repository of the schema changes.

Why do we need a Database project?

While developing any application, the developer has to work on many database tasks such as creating tables, triggers, stored procedures, functions, etc. It is difficult to manage the scripts at the time of deployment. Also, it is tedious to review the changes made by the developer during development. The database project in Visual studio addresses these issues.

How to create a database project?

  1. Create a new project in visual studio. Select the SQL Server Database Project, as shown below.

New project

2. Right-click on the project and select Import🡪Database

Importing database

3. After this, you get one popup as follows. Click on ‘Select Connection…’ option to import the database.

Import database

4. You will receive another popup to select the connection properties of your database. After entering the credentials (and authenticating successfully), you will get the dropdown filled with a list of databases on  the SQL server. Select the database for which you are creating the project.

Connection properties

5. Once you click on ‘Connect’, you will notice all the tables, procedures, functions, etc. which will get imported.

Import database summary

6. Check solution explorer for your database related artefacts.

Solution explorer

7. Now compare your project schema with the database schema after performing modifications to the database. Right-click on the solution and select Schema compare, as shown below.

Database demo

As you can see in the above image, there are two sections Source and Target.

Source: If you have made any changes in the database and you want to compare those on the target, then select the database name. If however, you have made changes in the database project that you want to compare with the database, then select your project path.

Target: It will always be with the source which will be compared. If you want, you can swap Source and Target. Once selected, click on ‘Compare’ to compare Source and Target schemas.

8. For example, I have added the Enquiry table in the database; Clicking on Compare allows you to see a list of modifications.

Database demo 8

The Action column in the above image is displayed if the changes are new or if there are any updates or deletions in the schema.

When you check the box and click on ‘Update’, all the changes will be applied to Target.

9. Now if you have made any changes in the database project and you want to execute those on the Production UAT database, then execute it in the same way as shown above.

10. In order to create the scripts for the changes, then compare the Database project with the Target Database. Then click on ‘Generate Scripts’.

Merits and Demerits of Database Project:

Merits:

  1. DDL (Data Definition Language) is readily available for all the objects.
  2. Deployment scripts can be easily generated.
  3. A database project also includes designers for working with these files.
  4. Version control can be done for the database through a series of check-in and check-outs for various operations performed on scripts and schema changes.
  5. Reviewing database changes is easier and allows  Dot Net developers to be more effective in terms of making changes and reviewing previous modifications done by team members.

Demerits:

  1. Schema designing is not available.
  2. References to external database sources cannot be created in the database project.
  3. The Visual studio database project only supports the SQL Server.

Introducing Visual Studio Mobile Center

Microsoft has recently launched ‘Visual Studio Mobile Center’ for the developer community. The purpose is to help in building and managing mobile apps through a set of cloud services. The Mobile Center supports applications built on several frameworks. It supports apps built on platforms like Swift, Java, Xamarin, React Native and Objective –C. The platform is currently in its “preview” period and a roadmap is in place to further build out services to be offered.

Today developers are expected to go beyond conventional approach to app building and their prime focus is on providing mobile users a Unique experience. Developers need a platform where they can build, test, deliver and monitor the apps as fast as possible on a continuous basis. Mobile Center, can reduce the time spent on creating a workflow by using the services provided by Mobile Center. It will allow the developers to concentrate on the primary task of creating a good app.

Some of the features in VS Mobile Center are:

  • Build apps automatically with pull request
  • Test apps on different mobile devices through the embedded automated UI tests
  • Monitor bugs and crashes for immediate diagnostics
  • Mobile analytics feature gives detailed insights on mobile usage and behavior
  • Apps written in any language can be brought into VS Mobile Center’s cloud and lifecycle services

The developers have a choice to work on end-to-end workflow provided by the VS Mobile Center or can choose to avail only a subset of the services.

VS Mobile Center is expected to evolve further with integration with HockeyApp and Test cloud apps. In addition to that, the future versions of VS Mobile Center will support Cordova and Universal Windows platform. Advanced features like advanced analytics and push notifications will also be a part of the future versions. Currently, it supports only lifecycle features like building, testing, crashing, Beta distribution and analytics. In Cloud features support authentication, easy tables and offline sync.To access the VS Mobile Center you can sign in using your existing HockeyApp credentials or use your GitHub account or Microsoft account.

At MetaSys Software we offer custom development using  ASP.Net, SQL Server, Telerik controls and Iron speed. We also have a strong team of Certified FileMaker Developers with experience in PHP & FileMaker solutions, FM Go as well as in building iOS apps.