Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Architecture
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
Bing
BizTalk
Book Excerpts
Build and Deploy
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Design Patterns
Development Process
Display Technologies
Distributed Computing
DotNetNuke
DSL
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
Internet Explorer 8.0
Interviews
iPhone
Iron Ruby
Java
Java Script
jQuery
LINQ
Linux
Mac OS X
MDX
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
Network
NHibernate
Object Oriented Development
Odata
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Python
Q&A
Rails
Rake
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Search
Security
Services
SharePoint
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
Tips
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WF
Whitepapers
Windows 7
Windows Azure
Windows Live
Windows Server
Windows Vista
WinForms
Workflow
WPF
XAML
XML
XNA
XSLT



CODE Training


 


CODE TRAINING

Reader rating:
Click here to read 9 comments about this article.
Article source: CoDe (2007 Nov/Dec)


Article Pages: < Previous - 1  2  3 4 5 - Next >


Introducing ADO.NET Entity Framework (Cont.)

Working with Beta 2

At the time of writing, Visual Studio 2008 Beta 2 is available as are ADO.NET Entity Framework Beta 2 and the ADO.NET Entity Framework Tools CTP 1. Eventually ADO.NET Entity Framework and its tools will be part of Visual Studio 2008, but currently it is necessary to install all three pieces. See the sidebars for the appropriate links.

"
It is important to note that you will need to do manual editing of the EDMX file for more complex scenarios.
"

The tools contain a wizard for creating a model from a database and a designer for editing the model. Since the tools are still currently in their first Community Technical Preview, expect them to evolve rapidly over the next few releases.

Build a Simple Entity Data Model

The first steps of learning ADO.NET Entity Framework involve using the wizard to create a simple Entity Data Model from an existing database. To follow these steps, it will be necessary not only to have the above programs and tools installed, but to also have access to a SQL Server or SQL Server Express database, so that you can create a simple EDM in a simple Windows Form application.

  1. Start by creating a new Windows Form project, and then add a new item to the project.
  2. In the item templates, select “ADO.NET Entity Data Model” which will open up the wizard.
  3. Click the database option as you will be creating an EDM from an existing database.
  4. On the next page of the wizard, shown in Figure 2, use the database drop-down list to select from an existing database connection or to create a new one on the fly. This example is based on the Northwind database.
  5. On this page, you have an opportunity to create a name that will be used for the Connection string in the application’s config file as well as for the main class that will give us access to the entities we are about to create. For this sample, I have renamed this “NWEntities”.
  6. On the last page, shown in Figure 3, you will have the ability to select which tables, views, or stored procedures from the database to include in the model. By default all are selected. For this example, leave all of the items selected, and then let the wizard finish its job.

Click for a larger version of this image.

Figure 2: Adding a new Entity Data Model to your project.

Click for a larger version of this image.

Figure 3: Selecting a database (in this case, a SQL Server Express database) to build your Entity Model from. Note the additional metadata in the connection string that the newly created subsequent classes will use.

The Visual EDM Designer

When the wizard is complete, you will see the new Model1.EDMX file. Double-clicking on the EDMX file will open up the model in the designer. The Tools CTP was released just before this article went to print and therefore, the article will not spend much time looking at the designer beyond a screenshot displayed in Figure 4. This is a section of what the model from the Northwind database will look like after the wizard has built it from the database.

Click for a larger version of this image.

Figure 4: Part of the view of the model generated from the Northwind database in the Entity Data Model Designer.

You can see that each entity is represented along with its properties and its relationships to other entities. The model displays the conceptual layer only and has an interface for mapping to the entities in the storage layer.

For links to more information about the designer, check the sidebar.

&


Resources

ADO.NET Orcas Forums

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=533&;SiteID=1

ADO.NET Team Blog

http://blogs.msdn.com/adonet

Project Astoria

http://blogs.msdn.com/astoriateam/archive/2007/07/18/welcome.aspx

Data Access Incubation Projects

http://msdn2.microsoft.com/en-us/data/bb419139.aspx

The LINQ Project

http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx

MSDN Data Platform Developer Center

http://msdn2.microsoft.com/data



Article Pages: < Previous - 1  2  3 4 5 - Next Page: 'A Brief Look at a Schema File' >>

Page 1: Introducing ADO.NET Entity Framework
Page 2: Working with Beta 2
Page 3: A Brief Look at a Schema File
Page 4: Deferred Loading
Page 5: LINQ to Entities

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3.8 out of 5

108 people have rated this article.

      iPhone iPad Developers Conference

 

Devscovery