Posts

How to connect to database using Server Explorer in Visual Studio

Image
Steps to connect to your database using Server Explorer in Visual Studio Open Visual Studio, Select View → Server Explorer Right Click on Data Connections and select Add Connection... If you are not connected to a database from Server Explorer then you will need to select Microsoft Server as the data source. You can connect to either localDb ((localdb)\v11.0) or SQL Express ( ./SQLEXPRESS ), In my case I am connecting to SQLEXPRESS which is hosted my machine(MYNA) so the name will be “ MYNA\SQLEXPRESS ”  and then select your existing database or you can define new database which will get created. Once you are done , You can check the database in the Server Explorer 

Entity Framework : How to create database using code

Image
This is a step-by-step walkthrough which will create a new database using C# code. We will create one console Application which will create an empty database and will also add new tables too. Pre-Requisities We need to have Visual Studio 2013 installed to complete this walkthrough.(You can use older version too like 2010 or 2012 to complete this tutorial.) Apart from that, You will also need to have NuGet installed on your Visual Studio. Steps : 1. Create new Application Open Visual Studio, Click File -> New -> Project Click Console Application under templates -> Visual C# -> Windows Enter Name as CreateNewDatabase and Select OK 2. Create the Model Now we will create two simple model(Employee, Manager) using classes. As a part of demo I'll define both in Program.cs but in a real word application we should define in two separate file/classes. Add the following two classes in Program.cs. public class Manager ...

What is NuGet and how to install it on Visual Studio 2013

NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers. How to install NuGet using Visual Studio Extension Manager : Open Visual Studio, Click Tools and then Extension Manager . Navigate to Online , Find NuGet Manager Extension and click Download In the Installer dialog box, click Install . When installation is complete, close and re-open Visual Studio. NuGet is now ready to use.