In this article I will explain how we can work with Dynamic Data Entities Web Application
which is available at the time of creating a project.
In this article I will show how we can implement CRUD
operation without writing a single line of code, and by just un-commenting a
line in Global.asax file.
The only thing you have to do is to add a reference in Global.asax
file with your project name you created. As my project name 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 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 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
This will create a project with a Master page, a Default
page, a Global.asax file along with script and css.
Now let us add Ado.NET Entity Data Model as we did in our
last article
As I am already having an connection I am not showing how to
add connection, I will proceed with what I have
Open Global.asax file from the solution explorer
You can find some code with comments, we will un-comment the
one we needed as follows
Here in place of YourDataContextType you have to
replace your context type which will be available in web.config or in Model.edmx
Now run your application
As I integrated 2 tables it is showing those tables, select
the required to perform CRUD operations.
I selected Employee and the details are as follows
In the department dropdown you can find out the entire
department listed as follows
If I select any that corresponding details were shown as
follows
Inserting details to Employee table, if you select Insert
New Item it will display as follows
Edit Update screen
Deleting a record:
Before delete: I will delete one of the record
Delete:
After delete:
Viewing Employees from Department
Details of selected Employee
Any comments welcome..
Please do feel free to ask for any queries...
The .NET Web Development and Tools group shipped a Dynamic Data project template with VS2012 that hard fails on the first line of code and the failure can be fixed by a simple mod to the template.
ReplyDeleteI guess DynamicData is a dying technology afterall. Hopefully the ASP.NET MVC team will pick it up an integrate it into ASP.NET MVC.
The Enterprise Structure is a set of technology in ADO.NET that support the development of data-oriented programs. Designers and designers of data-oriented programs have fought with the need to achieve two very different goals. They must model the organizations, connections, and reasoning of the business problems they are fixing, and they must also perform with the information engines used to store and recover the information. The information may span multiple storage space systems, each with its own protocols; even programs that perform with a single storage space program must balance the specifications of the storage space program against the specifications of writing efficient and maintainable application code.
ReplyDeleteThanks for your valuable comments. Please let me know if you need any help, I am always there to help
ReplyDelete