ARTICLE

Dynamic Data Entities Web Application

Posted by Dorababu M Articles | ADO.NET in C# January 04, 2013
In this article I will explain how to work with a Dynamic Data Entities Web Application and show how to implement a CRUD operation without writing a single line of code.
Reader Level:
Download Files:
 

In this article I will explain how to work with a Dynamic Data Entities Web Application which is available when a project is created.

In this article I will show how to implement a CRUD operation without writing a single line of code, and by just un-commenting a line in the Global.asax file.

The only thing you have to do is to add a reference in the Global.asax file with your project name you created. Since my project name is dynamicdataentities I will add this as a reference as follows:

using dynamicdataentities;

The only thing you have to do after this is to un-comment this line of code from the Global.asax file:

DefaultModel.RegisterContext(typeof(YourDataContextType), new ContextConfiguration() { ScaffoldAllTables = false });

You have to replace this with the following:

DefaultModel.RegisterContext(typeof(codeDBEntities), new ContextConfiguration() { ScaffoldAllTables = true });

Here codeDBEntities is nothing but the connection string which is available in the Web.config file or you can find it in Model.edmx.

First let us create a project by selecting ASP.NET Dynamic Data Entities Web Application as follows:

Figure 1.jpg

This will create a project with a Master page, a Default page and a Global.asax file along with script and css.

Now let us add an ADO.NET Entity Data Model as we did in our last article; see:

Figure 2.jpg

Figure 3.jpg

Since I already have a connection I am not showing how to add a connection; I will proceed with what I have.

Figure 4.jpg

Figure 5.jpg

Open the Global.asax file from the Solution Explorer:

Figure 6.jpg

You can find some code with comments, we will un-comment the one we need as follows:

Figure 7.jpg

Here in place of YourDataContextType you have to replace your context type which will be available in the web.config or Model.edmx:

Figure 8.jpg

Figure 9.jpg

Figure 10.jpg

Now run your application.

Figure 11.jpg

Since I integrated 2 tables it is showing those tables, select what is required to perform the CRUD operations.

I selected Employee and the details are as follows:

Figure 12.jpg

In the department dropdown you can determine the entire department listed, as follows:

Figure 13.jpg

If I select any then the corresponding details are shown as follows:

Figure 14.jpg

Inserting details into Employee table, if you select Insert New Item then it will display as follows:

Figure 15.jpg

Edit Update screen

Figure 16.jpg

Deleting a record

Before Delete

I will delete one of the record.

Figure 17.jpg

Figure 18.jpg

Figure 19.jpg

Viewing Employees from Department

Figure 20.jpg

Details of selected Employee

Figure 21.jpg

Login to add your contents and source code to this article
post comment
     

Would you please tell me how to focus first control of form view in insert and update page or when any field required.

Posted by ashok kumar Feb 07, 2013

good one...

Posted by Anil Kumar Jan 05, 2013
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter