sql server compact edition 3.5 and the entity framework rob sanders and matt lynch

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

Upload: trevor-sherman

Post on 23-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

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

SQL Server Compact Edition 3.5and the Entity Framework

Rob Sanders and Matt Lynch

Page 2: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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

Page 3: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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!

Page 4: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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> HmmmmRob> We’ve got to do a presentation on it!

Matt> Absolutely!

Page 5: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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, 2007Source: http://blogs.msdn.com/data/archive/2007/04/28/microsoft-s-data-access-strategy.aspx

Page 6: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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

Page 7: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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

Page 8: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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 spINNER JOIN Employee e ON sp.SalesPersonID = e.EmployeeIDINNER JOIN Contact c ON e.EmployeeID = c.ContactIDWHERE e.SalariedFlag = 1 AND e.HireDate >= '2006-01-01'

• Entity SQL– SELECT sp.FirstName, sp.LastName, sp.HireDate

FROM AdventureWorks.AdventureWorksDB.SalesPeople AS spWHERE e.HireDate >= '2006-01-01‘

– Only used for select statements

Page 9: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

Entity Framework Basics

Demos Happen Here!

• Entity Data Model• Basic Queries

Page 10: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

The SQL Server Family

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

Page 11: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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)

Page 12: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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!

Page 13: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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.

Page 14: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

Is Compact Edition Worthy?

Asked at www.stackoverflow.com:

“Has anyone used (or considered using) SQL Server Compact Edition 3.5?”

Page 15: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

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

Page 16: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

More Demonstrations

Demo• Create a Compact Edition Database– With Visual Studio– With C#

Page 17: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

Advanced Entity Framework

• Demos:– Concurrency– Many to Many– Table Per Type

• Grand Finale

Page 18: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

Further ReadingSQL Compact Edition Homepagehttp://www.microsoft.com/Sqlserver/2005/en/us/compact.aspx

Introduction to SQL Compact Editionhttp://support.microsoft.com/kb/920700

Download SQL CEhttp://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

Page 19: SQL Server Compact Edition 3.5 and the Entity Framework Rob Sanders and Matt Lynch

Fin

• Rob Sanders• http://internationalized.spaces.live.com• Twitter: AusRob• [email protected]

• Matt Lynch• http://matt-lynch.spaces.live.com• [email protected]