Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Popular Tags...

Tags

SnowCovered Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

A Quick Guide to Using ADO.NET Entity Framework

A Quick Guide to Using Entity Framework (ADO.NET)

 

If you’ve spent some years developing applications you are almost absolutely certain to be familiar with SQL. It is powerful but it is certainly not convenient to have to learn a completely different syntax and programming language to work with your data.

 

Then there’s the problem of database design. Most programmers work with Object oriented design and find it really hard to translate these objects into the Set based structure of an RDBMS. Normalization is a pain!

 

That’s why most projects need a database specialist. Someone who can make sense of all the data and make sure the business logic connects well to the database.

 

Entity Framework Translates Relational Data into Objects

 

ormapper

 

Taken in its simplest form, Microsoft’s Entity Framework is a O/R Mapper, i.e. an Object/Relational Mapper. It expresses the relational data in the database in form of Object that a programmer can use easily in his or her projects without worrying about relational queries and tables.

 

That solves a major problem, because programmers can directly implement their object oriented business logic and plan their applications better.

 

Entity Framework is slightly more than an O/R Mapper

 

In case you have been following programming news, you’re probably aware of other O/R Mappers. There’s Nhibernate for instance. Entity Framework is a more special because it integrates so well with Microsoft’s .Net paradigm and Visual Studio.

 

It also gives you access to Linq To Entities. LINQ is a great programming innovation that makes database queries a first class member of your program. You can integrate it right inside your business logic, no need to write special functions to retrieve your data.

 

So now that you’re convinced how cool Entity Framework is, let’s learn how you can use Entity framework in your projects and access database in a way you’ve never done before.

 

Get Entity Framework

 

Entity Framework is free. You can download it from Microsoft’s website. The latest version is Beta 3. You’ll also need the Visual Studio integration kit, .Net Framework 3.5, Visual Studio 2008 patch and Visual Studio SP1 upgrade. Quite a list; isn’t it? But definitely worth downloading.

 

Installing Entity framework is a little tricky. But here’s a link to a great guide that should make the job easy for you: http://www.installationwiki.org/Installing_ADO.NET_Entity_Framework

 

Let’s Make our First Entity Framework App

 

Entity Framework works as a layer that sits between your code and your database. Microsoft has provided a nice wizard to help you integrate Entity framework.

 

Add a new Entity Framework Model

Right click on your project in the Solutions Explorer, click on ‘Add new Item’ and choose ‘ADO .Net Entity Data Model’ from the dialog that appears. This item will only appear if you have successfully installed Entity Framework on your computer. If it doesn’t appear, check your installation.

 

This will bring up the Entity Data Model Wizard.

 

edm wiz

 

You can choose to ‘Generate from database’ or start with an ‘Empty Model’. In almost all the cases you would be Generating from a database because you don’t want to create an empty model and implement your logic by hand.

 

The next window you see will ask you to choose a connection for the database. If you’ve ever used the Data Model Wizard to create a connection earlier, you’ll see it in the list. Otherwise you will have to create a fresh connection by clicking on the ‘New Connection’ button which will bring you the following dialog box.

 

newcon

 

Here you can specify your data source, your server name, and the database login ID and the password if needed. Based on your input the Data Model Wizard will create a connection string. You can test your connection using the ‘Test Connection’ button to ensure that the connection is working alright.

 

When you click on ‘Next’ again the EDM Wizard will load the database objects and ask you to select the objects you wish to include in the Model. The

 

chooseobjects

 

The new version of the Entity Framework supports Stored procedures as well. Check the tables, views and stored procedures you want to include in your model and press Finish. This will generate the classes you need to work wit the database, and you will also see a graphical view of your Entities and the relationships between them (using primary and foreign keys).

 

datamodel

 

Our sample database has no relationships. Each block represents one object in the Entity model. You can work with. Now your objects are created. Entity Framework gives you a great deal of freedom in deciding how your objects are going to look and how they are going to behave.

 

In fact you can change the names of the Object properties from what they are in the database and also assign Stored procedures to common functions like Insert, Delete and Update. All this id done by the Object Mapper displayed at the bottom of the Entity Diagram.

 

ormapper1
ormapper2

 

Using the Mapper you can give your properties more descriptive names, and if you assign stored procedures to the functions, then the Entity framework will make it very easy for you to Save and Update your data.

 

Whew! Setting up the entity framework in your project is a time consuming job, but all that effort is going to pay you back many times in code. You are going to have to write less code to deal with your data. Let us learn how.

 

Working with Entity Framework in Code

 

In the Solutions Explorer, expand your Entity Model and you’ll see a Designer file for it. Double click the Designer file to open it. You will see the Class name with which you can access the Entity model. This should be the same as set by you when you created the Entity Model using the EDM Wizard. Let’s assume ours is called ShopperBase. Using the data in your project is now very easy.

 

Access your data through a Data Source

 

ormapper3

That’s all the code you need to write to populate your DataGrid with the data in the Members table. Very easy isn’t it? But the Members object can do much more than that. It’s a variable of the type ObjectQuery.

 

It’s very easy to do queries with Entity Framework. There are two primary methods. The first one is using the Entity SQL format which gives you a lot of power but requires a little learning. Luckily it is based on T-SQL so if you are already working with databases the conventional way, learning shouldn’t take long. Here’s a sample of code written this way: -

 

ormapper4

 

The example above gets all members who are verified.

 

But there’s another, and in my opinion better way to get data from your Entity Model. It is by using LINQ to Entities. If you have been coding in .Net 2 and above, you should already be familiar with LINQ. LINQ makes querying available to you inside your programming language. Through LINQ to entities you can query your database using LINQ queries. Here’s the same example re-written to work with LINQ.

 

ormapper5

 

See how simple this code is? And you can use the same syntax that you have been writing for your collections and other data inside your program. That’s why I recommend using the LINQ to Entities route to work with data from your Entity Framework.

 

Conclusion

This concludes our quick but comprehensive tutorial on the Entity Framework. We’ve covered the basics like installation, usage and coding. You should now be ready to work with Entity framework in your own projects. So start using this wonderful new technology today and get Object driven database access within your code.

 

Share the page?

A Quick Guide to Using Entity Framework - share this page - email email - del.icio.us del.icio.us - digg digg - reddit reddit

Feedback Comments

Feedback

SharePoint Web Parts


All Data Springs Web Parts Support WSS 3.0, SharePoint 2007, and SharePoint 2010 Frameworks

Please select license option for each web part you wish to purchase. We highly recommend the SharePoint Bundle to get all Data Springs Web Parts for maximum value!

 

 

      
Cart


Data Springs Sharepoint Bundle

Best Value! The Bundle gives you all 5 web parts in one package at a very attractive price! Best Value! We think you will be very happy with the SharePoint bundle and great price discounts you will receive. With your purchase all of the web parts below will be included.
 
 
 
 

Random Image Web Part

With Random Image for Sharepoint 2007, you can select multiple images to display randomly when the web part loads...
 
 
 
 

Stock Quote Web Part

Giving your site visitors relevant information is critical. With the Data Springs Stock Web Part you can provide your users with up to date financial information
 
 
 
 

Dynamic Image Rotator Web Part

Who would have thought? Adobe Flash® with Sharepoint! The FIRST and ONLY image rotation web part for Sharepoint using Flash Technology from Adobe! The Dynamic Image Rotator displays selected images and then rotates between the images. Several extended and optional features allow you to select the time to rotate each image, fade between
 
 
 
 

SharePoint Charts Web Part

The MOSS Chart Web Part is a web part built by Data Springs for the purpose of rendering several chart types based on data from a SharePoint list on a MOSS 2007 or WSS 3.0 Site
 
 
 
 

Dynamic News Ticker Web Part

Provide current news items with a user-friendly news ticker for your Sharepoint Portal. With millions of web sites offering information you need a fun way to display information and the solution is Flash News Ticker....
 
 
 
 

Tailored Text Web Part

 Tailored Text Web Part allows you to add text/html to your web site that can be different for anonymous users, registered users,  and even individual users specifically.

 
 
 
 

Dynamic Views Web Part

Dynamic Views is an excellent tool to:
Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. When it comes to technology and web site content, you now have the power to leverage this personalization directly with your users on your DotNetNuke® site

 
 
 
 

Dynamic Login Web Part

Your site content isn't vanilla, so why is your portal's login?

Add pizazz and functionality with Dynamic Login! Use custom templates, localization, redirection rules for various roles and many more features!
 
 
 
 


DNN Modules

DotNetNuke Modules


Data Springs offers cost-saving packages that fit your needs:

Purchase the Collection 6.0

Data Springs Collection 6.0

An entire tool chest to quickly build websites and construct complex, powerful, and relevant workflow. Elevate your design with custom registration, forms, displays, reports, user management, payments, Google maps,, SQL updates, and so much more!

Best Value!  Includes all DotNetNuke modules by Data Springs.

$ 495.00

Data Springs User Management Suite 3.0

All the tools you need to enhance user & profile management from A to Z!.  A comprehensive package with 5 feature-packed modules that offer extensive admin controls and easy user interface geared towards an effective and growth-oriented site!  .... more

 

Includes:  Dynamic Registration     Dynamic Login   ♦   Interactive User Import     Dynamic User Directory   ♦   Renewal Reminder    A value of more than $630.00!

 $ 369.00

 

 

Check out all our individual modules!

 

 View Dynamic Registration

Dynamic Registration 5.0 (new release on 6/12/2013)

Need custom fields and workflow for your registration? Get all the power and ease of use to create the registration and profile management just the way you want it... more

$ 199.00

View Dynamic Forms

Dynamic Forms 4.1 (released 5/16/2012)

Whether it's for marketing, sales, contact forms, scheduling, information requests, surveys, or to simply better understand your customer needs, the possibilities for creating powerfully effective forms are now easy and endless! ... more

$ 195.00

 

Dynamic Views 3.1 (new on 2/7/2013)

Now have an easy yet feature-rich reporting module with custom defined display templates and unlimited search options from  Dynamic Forms or any data source like a table, view or custom query!  ... more

$ 169.00

 View Dynamic Login Module

Dynamic Login 4.1 (released 10/19/2011)

Add pizazz and functionality to your site login! Dynamic Login gives you custom templates, localization, redirection rules, SQL Validation, and Single SignOn. Want more? How about Facebook Connect, LinkedIN, and Twitter, too? Your login has never been so exciting!.   ... more

$ 149.00

 View Interactive User Import

Interactive User Import 3.0 (released 8/17/2011)

Interactive User Import provides you with the functionality to easily and quickly import users into DotNetNuke and Dynamic Registration, through a streamlined and well-documented wizard that includes many advanced features... more

$ 149.00

 View Dynamic User Directory

Dynamic User Directory 4.1 (released 4/26/2012)

The perfect compliment for extending your portals users and community! An essential ingredient for managing dynamic user information, is being able to sort key fields and create useful user directories and custom report information... more

$ 179.00

 View Renewal Reminder

Renewal Reminder 1.3

Renewal Reminder provides you with the functionality to setup email notifications for users that their security role will soon expire. After installing your renewal / security role reminder module you can now setup scheduled notifications to be distributed to your users... more

$ 129.99
 View Opt In Email

Opt In Email 5.0 (new on 4/17/2013)

'Relationship Building' and 'Communication' are two essential nuts and bolts for a business to prosper. This module allows you to bridge both of these and easily generate continuous awareness of your web site, products and services. Your prospects and customers will greatly appreciate this feature... more

$ 179.00

 View Tailored Text

Tailored Text 3.0

Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. Leverage the power personalized content on your DotNetNuke site... more

$ 109.99
 View Stock Quote

Stock Quote 1.2

Giving your site visitors relevant information is critical. With the Data Springs Stock Module you can provide your users with up to date financial information... more

$ 109.99
 View Presentation Archive

Presentation Archive 2.0

With so much content on your web site, its important to give users an easy method for finding and retrieving content. Presentation Archive allows you to categorize, organize and present content within your DotNetNuke site for presentations, educational material, videos, and almost any document... more

$ 124.99
 View Real Estate

Real Estate 2.3

Real Estate 2.3 is a feature rich and user-friendly module that allows your portal users the ability to create real estate listings on your site... more

$ 149.99
 View Dynamic Image Rotator

Dynamic Image Rotator 3.3

Dynamic Image Rotator displays selected images and then rotates between the images using the Adobe® Flash® platform.  Several extended and optional features allow you to select the time to rotate each image, fade between images, and also display the images in either sequental or random order... more

$49.99
 View Info Pics Gallery

Info Pics Gallery

The Info Pics Gallery Module allows you to display thumbnail pictures with information to the user about each picture, along with a detailed description regarding the set of pictures and several other optional links... more

 $ 69.99
 View Testimonials Module

Testimonials

The Testimonials Module allows you to display customer testimonials on your site, as well as an easy method for users to submit testimonials about your web site, services, or products... more

 $ 49.99
 View Dynamic Info Cube

Dynamic Info Cube

Take your web site out of the box! Looking for a creative and interesting way to showcase information and content on your site? With millions of web sites offering information you need a fun way to display information and the solution is Dynamic Info Cube... more

$ 99.95
 Search Engine Optimization Cloud Module for DotNetNuke

Dynamic Tags

Nearly every web site developer would agree that search engine optimization is one of key aspects to a successful web site. Part of search engine optimization requires providing search engines that crawl your web site with appropriate and meaningful content... more

$ 69.99
 View Page Tags

Page Tags

'Page Tags' pulls in search terms that users searched to find the current page. There are many benefits to displaying these search words that delivered the user to the site, find our more details ... more

$ 59.99
 Random Rounded Images

Random Rounded Images

Random Rounded Images is an easy to use upgraded version of the images module included with DNN. With RRI, you can select multiple images to display randomly when the module loads. For example, you can add 10 images to the module, and each time you refresh or load the page one of those images will... more

$ 49.99
 View Back on Track

Back on Track

Giving your site visitors fast access to areas of interest is vital to your web site's ease of use and ultimately - sales potential... more

$ 99.99
 

Dynamic News Ticker 2.0

Dynamic News Ticker allows you to scroll through news items in a horizontal or veritical direction with administrative features that allow you to easily customize the look of your news ticker. Each instance of Dynamic News Ticker can be set up to have different sizes, scroll directions, scroll speed... more

$ 39.00
 View Quick Poll

Quick Poll

Give your users a voice, while also providing an important way for you to gather opinions from your users and measure visitors' responses to questions on your site! Polls are significant because they can provide a way for your web site visitors to share ideas and vote on topics of your choosing... more

$ 39.99
 View Flash Contacts

Dynamic Contacts 2.0

Dynamic Contacts is the fastest and easiest way you can help visitors of your website connect with your key personnel... more

$ 79.99
     

 

 

 
 

Join our mailing list...

Get current news and events the easy way
 
 
   
Subscribe Me

Recent Blogs...

 
Copyright 2005 - 2011 by Data Springs, Inc.