Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch.

Similar presentations


Presentation on theme: "SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch."— Presentation transcript:

1 SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

2 About Us Matt is an independent contractor who specializes in SharePoint, Entity Framework and C# and the.Net Framework. http://matt-lynch.spaces.live.com Rob is a consultant for Readify in Brisbane and spends his time between SQL Server, Team Foundation Server and BizTalk. http://internationalized.spaces.live.com

3 Presentation Agenda Introduction to the ADO Entity Framework Overview of SQL Server Compact Edition 3.5 Entity Framework Fundamentals Followed by.. Advanced Entity Framework Finally.. Entity Framework and SQL Compact Edition – Together!

4 Origins of this Presentation Rob> Hey mate, I’m working with LINQ to SQL and SQL Server Compact Edition Matt> Cool, hey did you know Compact Edition supports the Entity Framework? Rob> Hmmmm Rob> We’ve got to do a presentation on it! Matt> Absolutely!

5 Microsoft’s Data Access Strategy “ The Entity Data Platform is a multi-release vision, with future versions of reporting tools, replication, data definition, security, etc. all being built around a common Entity Data Model. “ – Mike Pizzo, Architect, Data Programmability April, 2007 Source: http://blogs.msdn.com/data/archive/2007/04/28/microsoft-s-data-access-strategy.aspxhttp://blogs.msdn.com/data/archive/2007/04/28/microsoft-s-data-access-strategy.aspx

6 Introducing the ADO.Net Entity Framework(EF) The goal of EF is to decrease the amount of code and maintenance required for data- oriented applications Entity Framework is central to Microsoft’s data access strategy for the.Net Framework Shipped with.Net Framework 3.5 SP 1 Underpinned by LINQ to Entities

7 The Entity Data Model The Entity Data Model is a Entity-Relationship data model which supports advanced features such as: – Abstract classes – Property / Entity renaming – Inheritance – Complex Types – Stored procedure mapping for insert, update and delete methods. – Mapping a single entity to multiple tables – Hiding join tables in collections – Documentation which populate Xml comments

8 Entity Data Model The Entity Data Model uses a.edmx file which consists of 3 sections – Conceptual Schema Definition Language(CSDL) – Store Schema Definition Language (SSDL) – Mapping Specification Language (MSL) Created by the Designer (or by hand, if you are game) Managed by the Metadata Workspace at run time Embedded in your assembly as a resource Entity Connection String specifies the data location – Use EntityConnectionStringBuilder to build a connection string at runtime Discover, Master, InfluenceSlide 8

9 Entity Framework Objects Metadata Workspace – Runtime component which maintains the CSDL, SSDL, MSL and CLR objects. Object State Manager – Maintains object state and identity management for entity type instances and relationship instances – Tracks query results, and provides logic to merge multiple overlapping query results. – It also performs in-memory change tracking when a user inserts, deletes, or modifies objects, and provides the change set for updates. This change set is used by the change processor to persist modifications Object Context – Primary class for interacting with data from a Entity Data Model – Encapsulates a connection to the database, the metadata workspace and the object state manager – Handle this like you would handle a Sql connection – open/close. For windows forms, use one ObjectContext per application instance. For web forms, use one ObjectContext per request – and use the EntityDataSource! Discover, Master, InfluenceSlide 9

10 Entity SQL Write queries independently of the data store with a more concise language – Provides a common query language across providers by extending the existing SQL language with constructs to work with strong notions of type, inheritance, and relationships from the Entity Data Model SQL – SELECT sp.FirstName, sp.LastName, sp.HireDate FROM SalesPerson sp INNER JOIN Employee e ON sp.SalesPersonID = e.EmployeeID INNER JOIN Contact c ON e.EmployeeID = c.ContactID WHERE e.SalariedFlag = 1 AND e.HireDate >= '2006-01-01' Entity SQL – SELECT sp.FirstName, sp.LastName, sp.HireDate FROM AdventureWorks.AdventureWorksDB.SalesPeople AS sp WHERE e.HireDate >= '2006-01-01‘ – Only used for select statements

11 Entity Framework Basics Demos Happen Here! Entity Data Model Basic Queries

12 The SQL Server Family The SQL Server 2008 Family of Products Enterprise Standard Workgroup Web Express Compact

13 Overview of SQL Compact Edition 3.5 Relational Database Flat File based Memory and CPU conscious design In-Process No installation ODBC/ADO Supported Runs on Windows Mobile and Desktop Platforms Also supported by the Sync Framework (SQL Server 2008)

14 What’s new in Compact Edition 3.5? Synchronization Options – Sync Framework, Remote Data Access, Merge replication Extended T-SQL support – CROSS APPLY – CAST – TOP Transaction Scope (On Desktops) – Read Committed (default), Repeatable Read, Serializable Identity Columns Unicode support Multi User, supports 256 connections – recommend < 100 LINQ to SQL and, of course, Entity Framework!

15 Be Honest, What’s the Downside? No support for Views No support for Triggers No support for Stored Procedures or UDFs Does not support smalldatetime, xml, varchar(max), nvarchar(max), char(c), varchar(n) datatypes You cannot integrate CLR assemblies No Full Text Search indexes No cross platform support No roles or privileges are supported …but it’s nicer than an XML file.

16 Is Compact Edition Worthy? Asked at www.stackoverflow.com:www.stackoverflow.com “Has anyone used (or considered using) SQL Server Compact Edition 3.5?”

17 Votes of Confidence "At work, we recently had to migrate a project that was designed for SQL Server Express to SQLCE. Once we started digging into it though, and saw what it DOES offer, we were convinced it was the right move. It supports LINQ, querying a lot of data [was] MUCH quicker than we thought it would” - BFree “I currently use SQL CE with NHibernate in a business application where the SQL CE database gets synchronized with Sync Framework via WCF to an SQL 2008 server. Works like a charm! especially generating the database from Nhibernate - mapping files [are] just awesome.“ - jkersch

18 More Demonstrations Demo Create a Compact Edition Database – With Visual Studio – With C#

19 Advanced Entity Framework Demos: – Concurrency – Many to Many – Table Per Type Grand Finale

20 Further Reading SQL Compact Edition Homepage http://www.microsoft.com/Sqlserver/2005/en/us/compact.aspx Introduction to SQL Compact Edition http://support.microsoft.com/kb/920700 Download SQL CE http://www.microsoft.com/downloads/details.aspx?FamilyID=85e0c3ce-3fa1-453a-8ce9- af6ca20946c3&displaylang=en Introduction to the Entity Framework (Wildermuth) http://www.theserverside.net/tt/articles/showarticle.tss?id=IntroducingEntityFramework ADO.net Entity Framework Overview (MSDN) http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx

21 Fin Rob Sanders http://internationalized.spaces.live.com Twitter: AusRob rob.sanders@gmail.com Matt Lynch http://matt-lynch.spaces.live.com M@ttLynch.net


Download ppt "SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch."

Similar presentations


Ads by Google