SlideShare a Scribd company logo
1 of 29
Adam Tuliper | Technical Evangelist, Microsoft
Christopher Harrison | Content Developer, Microsoft
Meet Adam Tuliper | @AdamTuliper
• Technical Evangelist, Microsoft
– Focused on Web, Data, Gaming, and Cloud Technologies
– Emphasis on secure development practices
• 20 years of industry experience as software architect
– Enterprise, startups, public sector, defense, healthcare, financial
industries
– channel9.msdn.com/Blogs/AdamTuliper
• Video content
– adamtuliper.com
Meet Christopher Harrison | @geektrainer
Content Developer
Focused on ASP.NET and Office 365 development
Microsoft Certified Trainer
Regular presenter at TechEd
Long time geek
Still misses his Commodore 64
Periodic blogger (blog.geektrainer.com)
Marathoner, husband, father of one four legged child
Setting Expectations
• Target Audience
–Web Developers
–Experience with C#
• Suggested Prerequisites/Supporting Material
–Introduction to MVC
• Microsoft Virtual Academy
– Free online learning tailored for IT Pros and Developers
– Over 2.6 million registered users
– Up-to-date, relevant training on variety of Microsoft products
• “Earn while you learn!”
– Get 50 MVA Points for this event!
– Visit http://aka.ms/MVA-Voucher
– Enter this code: MVCEntityFrmwrk (Expires 2Mar15)
Join the MVA Community!
Github Repository
• Has all demo files along with slides from this session
• http://github.com/MicrosoftLearning/EntityFramework
Course Topics
Implementing Entity Framework with MVC
01 | Introduction to Entity Framework 04 | Managing the database
02 | Beginning Code First 05 | Managing transactions
03 | Managing Relationships
06 | Integrating extra features and looking
forward
01 | Introduction to Entity Framework
Adam Tuliper | Technical Evangelist, Microsoft
Christopher Harrison | Content Developer, Microsoft
Module Overview
• Architecture
• Intro to Code First
• Generating EF Classes
Architecture
What is the Entity Framework
• It IS an ORM
• What’s an ORM?
– Maps your database types to your code types
– Avoids repetitive data access code
Customer Customer.cs
Customer
CustomerInfo.cs
ShipTo
EF Platforms
• EF 6.1 Any project that is full .NET 4+
• All Microsoft SQL Databases
• Web Forms, MVC, WPF, WCF, Web API, Web Forms
• Newer ones to include Azure Table Storage, Redis, Linux, etc
• Supported ADO.NET Providers
– https://msdn.microsoft.com/en-us/data/dd363565.aspx
Some supported features
• Full ORM to map objects to code
• Async Queries
• Connection Resiliency (retry)
• Stored Procedure mapping
• Reverse engineering existing database
• Using code to create database (code first)
• Concurrency detection
• Enum & Spatial Data support
High level view
• Simplified View
LINQ to Entities
Convert to
query, execute
Map results to
entities
EF System Components
Installing Entity Framework
• EF6 Requires Visual Studio 2010 or greater
• NuGet
– Install-package EntityFramework
• Comes as part of
– MVC, Web Forms, Web API templates if Identity is used
NuGet Primer
• Install-Package EntityFramework
– Latest non-beta
• Install-Package EntityFramework –pre
– pre release version
• Uninstall-Package EntityFramework
• Update-Package EntityFramework –reinstall (all projects)
• Update-Package EntityFramework -ProjectName MyProject
DEMODEMO
Installing and Managing Entity Framework Binaries
Intro to Code First
Code First
• The term ‘code first’ – a misnomer?
• Maps your POCO classes to database
• Uses at a minimum a DbContext and an entity (ie a class)
public class MusicStoreDbContext : DbContext
{
public DbSet<Album> Albums{ get; set; }
}
public class Album
{
public string Name { get; set; }
public decimal Cost{ get; set; }
}
DbContext
POCO (Entity)
DEMODEMO
Basic code first and scaffolding
public MusicContext() : base("MusicStoreConnection")
{
}
How does EF connect to your db?
• Could be cloud, App_Data folder, Intranet, Internet, other folder
Use context class name
to look for connect
string in web.config
No connect string.
Start database checks
Read connect string
Open Connection
Connect string named in
DbContext class
Look for SQL Express Look for (localdb)11
Look for
(localdb)mssqllocaldb
Read connect string
Open Connection
You should always specify a connection
string name when you intend to use a
connection string in the config file. This
ensures that if the connection string is
not present then Entity Framework will
throw rather than creating a new
database by convention.
<add name="MusicStoreContext" connectionString="Data
Source=(localdb)v12.0;.." providerName="System.Data.SqlClient" />
Helpful Hint
• Connecting to LocalDb be aware of instance names
– Typically v11.0, mssqllocaldb
– ProjectsV12 is created by data tools, ignore
• Connection string
– Data Source=(localdb)mssqllocaldb;
• Get versions / instances via
– sqllocaldb i
– sqllocaldb v
Viewing queries
• context.Database.Log = s => Console.WriteLine(s);
• Glimpse
– Install-package glimpse.mvc5
– install-package glimpse.ef6
• Interceptors
– Goes in .config
<interceptors>
<interceptor
type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger,
EntityFramework">
<parameters>
<parameter value=“MyAppsOutput.txt"/>
<parameter value="true" type="System.Boolean"/>
</parameters>
</interceptor>
</interceptors>
DEMODEMO
Viewing queries and connection info
Generating EF classes
Ways to generate
• Hand coding classes
• Use a visual designer
• Add->ADO.NET Entity Data Model
• Database First Entity Designer
DEMODEMO
Generating database and reverse engineering
Resources
• EF Resources
– https://msdn.microsoft.com/en-us/data/ef.aspx
• EF Team Blog
– http://blogs.msdn.com/b/adonet/
©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the
U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft
must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the
U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft
must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related Content

What's hot

Power-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellPower-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellQA or the Highway
 
devops online training in hyderabad
devops online training in hyderabaddevops online training in hyderabad
devops online training in hyderabadDIGITALSAI1
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiFlorent Batard
 
Selenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbaiSelenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbaiUnmesh Baile
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsChristopher Bartling
 
BDD presentation
BDD presentationBDD presentation
BDD presentationtemebele
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonTharindu Weerasinghe
 
The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)
The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)
The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)Alex Henthorn-Iwane
 
About Dewey Hong
About Dewey HongAbout Dewey Hong
About Dewey HongDewey Hong
 
Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs VMware Tanzu
 
Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...
Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...
Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...VibrantGroup
 
Behavior Driven Development (BDD)
Behavior Driven Development (BDD)Behavior Driven Development (BDD)
Behavior Driven Development (BDD)Ajay Danait
 
Guided Path to DevOps Career.
Guided Path to DevOps Career.Guided Path to DevOps Career.
Guided Path to DevOps Career.wahabwelcome
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Enea Gabriel
 
Refactoring legacy code driven by tests - ITA
Refactoring legacy code driven by tests -  ITARefactoring legacy code driven by tests -  ITA
Refactoring legacy code driven by tests - ITALuca Minudel
 
DATA SCIENCE TRAINING IN CHENNAI
DATA SCIENCE TRAINING IN CHENNAIDATA SCIENCE TRAINING IN CHENNAI
DATA SCIENCE TRAINING IN CHENNAIshivajirao12345
 
10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!Caleb Jenkins
 
angular js and node js training in hyderabad
angular js and node js training in hyderabadangular js and node js training in hyderabad
angular js and node js training in hyderabadphp2ranjan
 

What's hot (19)

Power-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellPower-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua Russell
 
devops online training in hyderabad
devops online training in hyderabaddevops online training in hyderabad
devops online training in hyderabad
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansai
 
Selenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbaiSelenium-corporate-training-in-mumbai
Selenium-corporate-training-in-mumbai
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And Friends
 
BDD presentation
BDD presentationBDD presentation
BDD presentation
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
 
CV_Sydul_Fahim_Pantha
CV_Sydul_Fahim_PanthaCV_Sydul_Fahim_Pantha
CV_Sydul_Fahim_Pantha
 
The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)
The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)
The Carrier DevOps Trend (Presented to Okinawa Open Days Conference)
 
About Dewey Hong
About Dewey HongAbout Dewey Hong
About Dewey Hong
 
Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs
 
Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...
Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...
Jboss Application Server training-course-navi-mumbai-jboss-course-provider-na...
 
Behavior Driven Development (BDD)
Behavior Driven Development (BDD)Behavior Driven Development (BDD)
Behavior Driven Development (BDD)
 
Guided Path to DevOps Career.
Guided Path to DevOps Career.Guided Path to DevOps Career.
Guided Path to DevOps Career.
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
 
Refactoring legacy code driven by tests - ITA
Refactoring legacy code driven by tests -  ITARefactoring legacy code driven by tests -  ITA
Refactoring legacy code driven by tests - ITA
 
DATA SCIENCE TRAINING IN CHENNAI
DATA SCIENCE TRAINING IN CHENNAIDATA SCIENCE TRAINING IN CHENNAI
DATA SCIENCE TRAINING IN CHENNAI
 
10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!
 
angular js and node js training in hyderabad
angular js and node js training in hyderabadangular js and node js training in hyderabad
angular js and node js training in hyderabad
 

Viewers also liked

C++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of ClassC++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of ClassYogendra Rampuria
 
06 integrating extra features and looking forward
06   integrating extra features and looking forward06   integrating extra features and looking forward
06 integrating extra features and looking forwardМарина Босова
 
000 introduction
000 introduction000 introduction
000 introductionsivorka
 
001 hosting
001 hosting001 hosting
001 hostingsivorka
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015Matt Raible
 
Lecture-03 Introduction to UML
Lecture-03 Introduction to UMLLecture-03 Introduction to UML
Lecture-03 Introduction to UMLartgreen
 
Unified Modelling Language
Unified Modelling LanguageUnified Modelling Language
Unified Modelling LanguageR A Akerkar
 
Mva stf module 6 - rus
Mva stf module 6 - rusMva stf module 6 - rus
Mva stf module 6 - rusMaxim Shaptala
 
презентация привязка модели и валидация данных
презентация   привязка модели и валидация данныхпрезентация   привязка модели и валидация данных
презентация привязка модели и валидация данныхsivorka
 
Mva stf module 5 - rus
Mva stf module 5 - rusMva stf module 5 - rus
Mva stf module 5 - rusMaxim Shaptala
 
05 cерверные элементы управления презентация
05 cерверные элементы управления   презентация05 cерверные элементы управления   презентация
05 cерверные элементы управления презентацияsivorka
 

Viewers also liked (20)

C++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of ClassC++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of Class
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
03 managing relationships
03   managing relationships03   managing relationships
03 managing relationships
 
02 beginning code first
02   beginning code first02   beginning code first
02 beginning code first
 
04 managing the database
04   managing the database04   managing the database
04 managing the database
 
06 integrating extra features and looking forward
06   integrating extra features and looking forward06   integrating extra features and looking forward
06 integrating extra features and looking forward
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity framework
 
000 introduction
000 introduction000 introduction
000 introduction
 
001 hosting
001 hosting001 hosting
001 hosting
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015
 
Lecture-03 Introduction to UML
Lecture-03 Introduction to UMLLecture-03 Introduction to UML
Lecture-03 Introduction to UML
 
Unified Modelling Language
Unified Modelling LanguageUnified Modelling Language
Unified Modelling Language
 
Mva stf module 6 - rus
Mva stf module 6 - rusMva stf module 6 - rus
Mva stf module 6 - rus
 
презентация привязка модели и валидация данных
презентация   привязка модели и валидация данныхпрезентация   привязка модели и валидация данных
презентация привязка модели и валидация данных
 
Mva stf module 5 - rus
Mva stf module 5 - rusMva stf module 5 - rus
Mva stf module 5 - rus
 
05 cерверные элементы управления презентация
05 cерверные элементы управления   презентация05 cерверные элементы управления   презентация
05 cерверные элементы управления презентация
 

Similar to Adam Tuliper & Christopher Harrison | Technical Evangelist and Content Developer

Microsoft Cloud Computing - Windows Azure Platform
Microsoft Cloud Computing - Windows Azure PlatformMicrosoft Cloud Computing - Windows Azure Platform
Microsoft Cloud Computing - Windows Azure PlatformDavid Chou
 
Azure presentation nnug dec 2010
Azure presentation nnug  dec 2010Azure presentation nnug  dec 2010
Azure presentation nnug dec 2010Ethos Technologies
 
Top 10 Things in Visual Studio 2008 since 2005
Top 10 Things in Visual Studio 2008 since 2005Top 10 Things in Visual Studio 2008 since 2005
Top 10 Things in Visual Studio 2008 since 2005ukdpe
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Mark Ginnebaugh
 
Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionDonRobins
 
Technology Roadmap by ericnel
Technology Roadmap by ericnelTechnology Roadmap by ericnel
Technology Roadmap by ericnelEric Nelson
 
Building Social Enterprise with Ruby and Salesforce
Building Social Enterprise with Ruby and SalesforceBuilding Social Enterprise with Ruby and Salesforce
Building Social Enterprise with Ruby and SalesforceRaymond Gao
 
Daniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days OcDaniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days OcDaniel Egan
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudMicrosoft ArcReady
 
Build Apps Using Dynamic Languages
Build Apps Using Dynamic LanguagesBuild Apps Using Dynamic Languages
Build Apps Using Dynamic LanguagesWes Yanaga
 
End to End .NET Development on Mac
End to End .NET Development on MacEnd to End .NET Development on Mac
End to End .NET Development on MacMike James
 
Arc Ready Cloud Computing
Arc Ready Cloud ComputingArc Ready Cloud Computing
Arc Ready Cloud ComputingPhilip Wheat
 
Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010DavidGristwood
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web DevelopmentRobert J. Stein
 
Azure Services Platform_Partner_Briefing
Azure Services Platform_Partner_BriefingAzure Services Platform_Partner_Briefing
Azure Services Platform_Partner_BriefingWes Yanaga
 
Microsoft-Azure-Overvi2222222222222ew.pptx
Microsoft-Azure-Overvi2222222222222ew.pptxMicrosoft-Azure-Overvi2222222222222ew.pptx
Microsoft-Azure-Overvi2222222222222ew.pptxsaidbilgen
 
Elevate london dec 2014.pptx
Elevate london dec 2014.pptxElevate london dec 2014.pptx
Elevate london dec 2014.pptxPeter Chittum
 

Similar to Adam Tuliper & Christopher Harrison | Technical Evangelist and Content Developer (20)

Microsoft Cloud Computing - Windows Azure Platform
Microsoft Cloud Computing - Windows Azure PlatformMicrosoft Cloud Computing - Windows Azure Platform
Microsoft Cloud Computing - Windows Azure Platform
 
Azure presentation nnug dec 2010
Azure presentation nnug  dec 2010Azure presentation nnug  dec 2010
Azure presentation nnug dec 2010
 
Top 10 Things in Visual Studio 2008 since 2005
Top 10 Things in Visual Studio 2008 since 2005Top 10 Things in Visual Studio 2008 since 2005
Top 10 Things in Visual Studio 2008 since 2005
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51
 
Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact Edition
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
 
Technology Roadmap by ericnel
Technology Roadmap by ericnelTechnology Roadmap by ericnel
Technology Roadmap by ericnel
 
Building Social Enterprise with Ruby and Salesforce
Building Social Enterprise with Ruby and SalesforceBuilding Social Enterprise with Ruby and Salesforce
Building Social Enterprise with Ruby and Salesforce
 
Daniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days OcDaniel Egan Msdn Tech Days Oc
Daniel Egan Msdn Tech Days Oc
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The Cloud
 
Resume
ResumeResume
Resume
 
Build Apps Using Dynamic Languages
Build Apps Using Dynamic LanguagesBuild Apps Using Dynamic Languages
Build Apps Using Dynamic Languages
 
End to End .NET Development on Mac
End to End .NET Development on MacEnd to End .NET Development on Mac
End to End .NET Development on Mac
 
Arc Ready Cloud Computing
Arc Ready Cloud ComputingArc Ready Cloud Computing
Arc Ready Cloud Computing
 
Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010Understanding the Windows Azure Platform - Dec 2010
Understanding the Windows Azure Platform - Dec 2010
 
Resume
ResumeResume
Resume
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
 
Azure Services Platform_Partner_Briefing
Azure Services Platform_Partner_BriefingAzure Services Platform_Partner_Briefing
Azure Services Platform_Partner_Briefing
 
Microsoft-Azure-Overvi2222222222222ew.pptx
Microsoft-Azure-Overvi2222222222222ew.pptxMicrosoft-Azure-Overvi2222222222222ew.pptx
Microsoft-Azure-Overvi2222222222222ew.pptx
 
Elevate london dec 2014.pptx
Elevate london dec 2014.pptxElevate london dec 2014.pptx
Elevate london dec 2014.pptx
 

More from Maxim Shaptala

More from Maxim Shaptala (7)

Mva stf module 4 - rus
Mva stf module 4 - rusMva stf module 4 - rus
Mva stf module 4 - rus
 
Mva stf module 3 - rus
Mva stf module 3 - rusMva stf module 3 - rus
Mva stf module 3 - rus
 
Mva stf module 2 - rus
Mva stf module 2 - rusMva stf module 2 - rus
Mva stf module 2 - rus
 
Mva stf module 1 - rus
Mva stf module 1 - rusMva stf module 1 - rus
Mva stf module 1 - rus
 
02 beginning code first
02   beginning code first02   beginning code first
02 beginning code first
 
file handling in c
file handling in cfile handling in c
file handling in c
 
file handling in c++
file handling in c++file handling in c++
file handling in c++
 

Recently uploaded

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 

Recently uploaded (20)

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 

Adam Tuliper & Christopher Harrison | Technical Evangelist and Content Developer

  • 1. Adam Tuliper | Technical Evangelist, Microsoft Christopher Harrison | Content Developer, Microsoft
  • 2. Meet Adam Tuliper | @AdamTuliper • Technical Evangelist, Microsoft – Focused on Web, Data, Gaming, and Cloud Technologies – Emphasis on secure development practices • 20 years of industry experience as software architect – Enterprise, startups, public sector, defense, healthcare, financial industries – channel9.msdn.com/Blogs/AdamTuliper • Video content – adamtuliper.com
  • 3. Meet Christopher Harrison | @geektrainer Content Developer Focused on ASP.NET and Office 365 development Microsoft Certified Trainer Regular presenter at TechEd Long time geek Still misses his Commodore 64 Periodic blogger (blog.geektrainer.com) Marathoner, husband, father of one four legged child
  • 4. Setting Expectations • Target Audience –Web Developers –Experience with C# • Suggested Prerequisites/Supporting Material –Introduction to MVC
  • 5. • Microsoft Virtual Academy – Free online learning tailored for IT Pros and Developers – Over 2.6 million registered users – Up-to-date, relevant training on variety of Microsoft products • “Earn while you learn!” – Get 50 MVA Points for this event! – Visit http://aka.ms/MVA-Voucher – Enter this code: MVCEntityFrmwrk (Expires 2Mar15) Join the MVA Community!
  • 6. Github Repository • Has all demo files along with slides from this session • http://github.com/MicrosoftLearning/EntityFramework
  • 7. Course Topics Implementing Entity Framework with MVC 01 | Introduction to Entity Framework 04 | Managing the database 02 | Beginning Code First 05 | Managing transactions 03 | Managing Relationships 06 | Integrating extra features and looking forward
  • 8. 01 | Introduction to Entity Framework Adam Tuliper | Technical Evangelist, Microsoft Christopher Harrison | Content Developer, Microsoft
  • 9. Module Overview • Architecture • Intro to Code First • Generating EF Classes
  • 11. What is the Entity Framework • It IS an ORM • What’s an ORM? – Maps your database types to your code types – Avoids repetitive data access code Customer Customer.cs Customer CustomerInfo.cs ShipTo
  • 12. EF Platforms • EF 6.1 Any project that is full .NET 4+ • All Microsoft SQL Databases • Web Forms, MVC, WPF, WCF, Web API, Web Forms • Newer ones to include Azure Table Storage, Redis, Linux, etc • Supported ADO.NET Providers – https://msdn.microsoft.com/en-us/data/dd363565.aspx
  • 13. Some supported features • Full ORM to map objects to code • Async Queries • Connection Resiliency (retry) • Stored Procedure mapping • Reverse engineering existing database • Using code to create database (code first) • Concurrency detection • Enum & Spatial Data support
  • 14. High level view • Simplified View LINQ to Entities Convert to query, execute Map results to entities EF System Components
  • 15. Installing Entity Framework • EF6 Requires Visual Studio 2010 or greater • NuGet – Install-package EntityFramework • Comes as part of – MVC, Web Forms, Web API templates if Identity is used
  • 16. NuGet Primer • Install-Package EntityFramework – Latest non-beta • Install-Package EntityFramework –pre – pre release version • Uninstall-Package EntityFramework • Update-Package EntityFramework –reinstall (all projects) • Update-Package EntityFramework -ProjectName MyProject
  • 17. DEMODEMO Installing and Managing Entity Framework Binaries
  • 18. Intro to Code First
  • 19. Code First • The term ‘code first’ – a misnomer? • Maps your POCO classes to database • Uses at a minimum a DbContext and an entity (ie a class) public class MusicStoreDbContext : DbContext { public DbSet<Album> Albums{ get; set; } } public class Album { public string Name { get; set; } public decimal Cost{ get; set; } } DbContext POCO (Entity)
  • 20. DEMODEMO Basic code first and scaffolding
  • 21. public MusicContext() : base("MusicStoreConnection") { } How does EF connect to your db? • Could be cloud, App_Data folder, Intranet, Internet, other folder Use context class name to look for connect string in web.config No connect string. Start database checks Read connect string Open Connection Connect string named in DbContext class Look for SQL Express Look for (localdb)11 Look for (localdb)mssqllocaldb Read connect string Open Connection You should always specify a connection string name when you intend to use a connection string in the config file. This ensures that if the connection string is not present then Entity Framework will throw rather than creating a new database by convention. <add name="MusicStoreContext" connectionString="Data Source=(localdb)v12.0;.." providerName="System.Data.SqlClient" />
  • 22. Helpful Hint • Connecting to LocalDb be aware of instance names – Typically v11.0, mssqllocaldb – ProjectsV12 is created by data tools, ignore • Connection string – Data Source=(localdb)mssqllocaldb; • Get versions / instances via – sqllocaldb i – sqllocaldb v
  • 23. Viewing queries • context.Database.Log = s => Console.WriteLine(s); • Glimpse – Install-package glimpse.mvc5 – install-package glimpse.ef6 • Interceptors – Goes in .config <interceptors> <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework"> <parameters> <parameter value=“MyAppsOutput.txt"/> <parameter value="true" type="System.Boolean"/> </parameters> </interceptor> </interceptors>
  • 24. DEMODEMO Viewing queries and connection info
  • 26. Ways to generate • Hand coding classes • Use a visual designer • Add->ADO.NET Entity Data Model • Database First Entity Designer
  • 27. DEMODEMO Generating database and reverse engineering
  • 28. Resources • EF Resources – https://msdn.microsoft.com/en-us/data/ef.aspx • EF Team Blog – http://blogs.msdn.com/b/adonet/
  • 29. ©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. ©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Editor's Notes

  1. 1
  2. Talk about nuget packages, upgrading, rolling back, etc. IBM supplies ADO.NET data providers for access to DB2, Informix, and U2 databases. Any ADO.NET Data Provider?
  3. Update-Package -Reinstall (reinstall all packages in all projects)
  4. Create MVC app without identity, Install-package entityframework Create MVC app with identity, show it already exists. Show how to upgrade, remove, reinstall. Update-Package EntityFramework (maybe –pre if theres time)
  5. Create a new console app, then we’ll do web. Install-package EF Add class public class Album { public int AlbumId { get; set; } public int GenreId { get; set; } public int ArtistId { get; set; } public string Title { get; set; } public decimal Price { get; set; } public string AlbumArtUrl { get; set; } } public class MusicContext : DbContext { public DbSet<Album> Albums { get; set; } } 4. Run the app. Explain the database is created because of connection string in the name in DbContext 5. If DbContext doesn’t have a connect string, we look for the name of the context class connection string. If that’s not found, we try to create SQLExpress, local db 12, local db 11 6. Add a connection string and show that new database using (var context = new MusicContext()) { var albums = context.Albums.ToList(); Console.WriteLine(albums.Count()); context.Albums.Add(new Album() { AlbumArtUrl="http://no.com", AlbumId=1, ArtistId=1, GenreId=2, Price=9.99m, Title="My Album"}); context.SaveChanges(); albums = context.Albums.ToList(); Console.WriteLine(albums.Count()); }
  6. DB name will be that of the connection string name, ie Data Source=(localdb)\mssqllocaldb;Initial Catalog=MusicStoreConnection;Integrated Security=True public MusicContext() : base("MusicStoreConnection") { } <connectionStrings> <add name="MusicStoreContext" connectionString="Data Source=(localdb)\v12.0; Initial Catalog=MusicStoreDev; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|MusicStoreDev.mdf" providerName="System.Data.SqlClient" /> </connectionStrings>
  7. <interceptors>   <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework">     <parameters>       <parameter value=“MyAppsOutput.txt"/>       <parameter value="true" type="System.Boolean"/>     </parameters>   </interceptor> </interceptors>
  8. //View queries context.Database.Log = s => Console.WriteLine(s); //Log connection Console.WriteLine(context.Database.Connection.ConnectionString); Using glimpse Install-package glimpse.mvc5 install-package glimpse.entityframework Inside the <entityFramework> element <interceptors>   <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework">     <parameters>       <parameter value=“MyAppsOutput.txt"/>       <parameter value="true" type="System.Boolean"/>     </parameters>   </interceptor> </interceptors>
  9. Discuss manual method, deprecating the designer, and revere engineering
  10. Look briefly at dialog Choose an existing database with music store information in it and reverse engineer it. Discuss we’ll talk about the database more in module 4