SlideShare a Scribd company logo
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

PPTX
05 managing transactions
PPTX
Team Foundation Server Process Templates For Effective Project Management
PDF
Architecting a Large Software Project - Lessons Learned
PDF
Using Clojure, NoSQL Databases and Functional-Style JavaScript to Write Gext-...
PPTX
Team Foundation Server - Tracking & Reporting
PPTX
Selenium + Specflow
PDF
Introcution to EJB
PPTX
Visual Studio LightSwitch (Beta 1) Overview
05 managing transactions
Team Foundation Server Process Templates For Effective Project Management
Architecting a Large Software Project - Lessons Learned
Using Clojure, NoSQL Databases and Functional-Style JavaScript to Write Gext-...
Team Foundation Server - Tracking & Reporting
Selenium + Specflow
Introcution to EJB
Visual Studio LightSwitch (Beta 1) Overview

What's hot (19)

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

Viewers also liked (20)

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

Similar to 01 introduction to entity framework (20)

PPTX
Microsoft Cloud Computing - Windows Azure Platform
PPTX
Azure presentation nnug dec 2010
PPT
Top 10 Things in Visual Studio 2008 since 2005
PDF
Getting Started with Sql Server Compact Edition
PDF
Getting Started with SQL Server Compact Edition 3.51
PPTX
05 entity framework
PPTX
Technology Roadmap by ericnel
PPTX
Building Social Enterprise with Ruby and Salesforce
PPT
Daniel Egan Msdn Tech Days Oc
PPT
ArcReady - Architecting For The Cloud
PPT
Build Apps Using Dynamic Languages
PDF
End to End .NET Development on Mac
PPT
Arc Ready Cloud Computing
PPTX
Understanding the Windows Azure Platform - Dec 2010
DOC
PPT
Advanced Web Development
PPT
Azure Services Platform_Partner_Briefing
PPTX
Microsoft-Azure-Overvi2222222222222ew.pptx
PDF
Elevate london dec 2014.pptx
Microsoft Cloud Computing - Windows Azure Platform
Azure presentation nnug dec 2010
Top 10 Things in Visual Studio 2008 since 2005
Getting Started with Sql Server Compact Edition
Getting Started with SQL Server Compact Edition 3.51
05 entity framework
Technology Roadmap by ericnel
Building Social Enterprise with Ruby and Salesforce
Daniel Egan Msdn Tech Days Oc
ArcReady - Architecting For The Cloud
Build Apps Using Dynamic Languages
End to End .NET Development on Mac
Arc Ready Cloud Computing
Understanding the Windows Azure Platform - Dec 2010
Advanced Web Development
Azure Services Platform_Partner_Briefing
Microsoft-Azure-Overvi2222222222222ew.pptx
Elevate london dec 2014.pptx

More from Maxim Shaptala (7)

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

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
history of c programming in notes for students .pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
AI in Product Development-omnex systems
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
L1 - Introduction to python Backend.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ai tools demonstartion for schools and inter college
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
history of c programming in notes for students .pptx
How to Migrate SBCGlobal Email to Yahoo Easily
AI in Product Development-omnex systems
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Design an Analysis of Algorithms I-SECS-1021-03
Design an Analysis of Algorithms II-SECS-1021-03
How Creative Agencies Leverage Project Management Software.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
ISO 45001 Occupational Health and Safety Management System
Odoo Companies in India – Driving Business Transformation.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
L1 - Introduction to python Backend.pptx
Softaken Excel to vCard Converter Software.pdf
PTS Company Brochure 2025 (1).pdf.......
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ai tools demonstartion for schools and inter college
Navsoft: AI-Powered Business Solutions & Custom Software Development
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx

01 introduction to entity framework

  • 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

  • #2: 1
  • #13: 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?
  • #17: Update-Package -Reinstall (reinstall all packages in all projects)
  • #18: 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)
  • #21: 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()); }
  • #22: 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>
  • #24: <interceptors>   <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework">     <parameters>       <parameter value=“MyAppsOutput.txt"/>       <parameter value="true" type="System.Boolean"/>     </parameters>   </interceptor> </interceptors>
  • #25: //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>
  • #27: Discuss manual method, deprecating the designer, and revere engineering
  • #28: 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