EzDb – Perform Database Operations Within Seconds

EzDB with its latest version 1.1.7 is now available on NuGet Gallery. The purpose of building this utility is to empower beginners as well as experienced software, web and desktop application developers working on Microsoft Technology Stack to perform Database Operations, Building ASP.NET MVC, WebForms, WinForms/WPF, WebAPIs or any other application that requires to perform data driven operations with SQL Server Management Studio within seconds by writing minimum line of code.

In the examples below, ASP.NET MVC is being used.

Installing EzDB

In Your ASP.NET Project right click references and choose “Manage Nuget Packages…”

Once you select the option, Nuget Package Manager will appear, Just Select Browse Option and Type EzDb as shown below:

Select  Install Option from the right pane and it will began your installation. Once Installation is completed, you will find EzDB reference in your references along a small indicator as shown below:

To make the EzDB Functional and to remove the indicator right click EzDb Reference and select properties and in specific version option choose false as shown below:

That’s it. You have successfully Installed EzDb. Now Lets see how to add EzDb Compatible Connection String.

Adding EzDB compatible connection string

There’s nothing change in connection strings if we talk about EzDB connection string as it is the same connection string which you use in your routine life to build asp.net data driven apps except the name of connection string. It must be DBHelperConnectionString as shown below:

<add name="DBHelperConnectionString" connectionString="YOUR_CONNECTION_STRING" providerName="System.Data.SqlClient" />

Once you added connection string correctly, you are now connected with the database. Now lets see how to perform CRUD.

Lets Take an example of small student database as shown below:

So according to the database the design of model should be:

In the above model you can see that [Schema(“dbo”)] is defined which is the schema name of your database table which in most cases is dbo, if you have other schema you may specify here, also the [Table(“information”)] represents the table in which database operations have to be performed.

Inserting With EzDB

If your model is same as your database table then you can simply insert data into your database as following:

Update with EzDb

For updating the complete table against an id you can use the following approach:

In order to update Specific Column, you might use ExecuteQuery() Function as shown below:

Deleting With EzDb

Deleting with EzDB is very simple and similar to update. You may delete the record as below:

Selecting / Loading Data with EzDb

Selecting the desired results of a query is not a big deal for EzDb, in order to select entire table you may use the following approach:

In case you want to select specific data you may use the following approach:

So you have seen how easy it is to perform CRUDs with EzDb, now if you want to simply execute any query for small or large operations from which output is not required like , insert, update and delete you may use ExecuteQuery() function as shown below:

Running Non-Select Queries With EzDb

Download the Latest Version of EzDB