120 likes | 360 Views
Entity Framework. MIS 324 Professor Sandvig. Outline. What is Entity Framework Benefits Drawbacks Example. What is Entity Framework. Microsoft’s newest data access technology Visual Studio: Examines database Creates objects that represent data schema LINQ (Language Integrated Query)
E N D
Entity Framework MIS 324 Professor Sandvig
Outline • What is Entity Framework • Benefits • Drawbacks • Example
What is Entity Framework • Microsoft’s newest data access technology • Visual Studio: • Examines database • Creates objects that represent data schema • LINQ (Language Integrated Query) • Replaces SQL • Select, sort, filter, etc.
Benefits • Eliminates disconnect between code & database • No sql statements in code • Use intellisense to write query • Automatic table joins • Full CRUD functionality • LINQ works on all data collections • Arrays, lists, dataviews, etc.
Drawbacks • Microsoft propriety technology • LINQ query syntax different than SQL • Better in many ways • Synchronization between database and entity objects • Change database • Rebuild entity objects
Example • Visual Studio: • Create new Dynamic Data Entities Web Site • Add new item: ADO Data Entity Model
Example • Select “Generate from Database” • Select Sql Server database • Express or full version • Note: table relationships MUST be defined in Database Diagram • Wizard creates new Namespace • Contains data objects that match database
Entity Model Designer Window • Note: many-to-many relationship
LINQ • Use LINQ to query against data objects
LINQ Syntax • Vardatatype uses implicit typing • Similar to DataTable
Example • Retail Store Example