SlideShare a Scribd company logo
AngularJS + Asp.Net Web Api
+ Signalr + EF6:前後端整合篇
開發技巧實戰系列(4/6) - Web 前後端整合
講師: 郭二文 (erhwenkuo@gmail.com)
Document, Source code & Training
Video (4/6)
• https://github.com/erhwenkuo/PracticalCoding
Previous Training Session Document,
Source code & Training Video (3/6)
• https://www.youtube.com/watch?v=z
UXYuCicBDc&feature=youtu.be
• http://www.slideshare.net/erhwenku
o/03-integrate-webapisignalr
Agenda
• ORM Technologies – Basic Concepts
• Entity Framework - Overview
• Developing & Testing of ASP.Net EF6
• Highchart , AngularJS ,Web API2 , SignalR2 + EF6 Integration
ORM Technologies – Basic
Concepts
Introduction to Object-Relational
Mapping (ORM)
• Object-Relational Mapping (ORM) is a programming technique for
automatic mapping and converting data
• Between relational database tables and object-oriented classes and
objects
• ORM creates a "virtual object database“
• Which can be used from within the programming language, e.g. C# or
Java
• ORM frameworks automate the ORM process
• A.k.a. object-relational persistence frameworks
Functionality of ORM
• ORM frameworks typically provide the following functionality:
• Creating object model by database schema
• Creating database schema by object model
• Querying data by object-oriented API
• Data manipulation operations
• CRUD – create, retrieve, update, delete
• ORM frameworks automatically generate SQL to perform the
requested data operations
ORM Mapping - Example
Relational
database schema
ORM Entities
(C# Classes)
ORM
Framework
ORM Advantages
• Developer productivity
• Writing less code
• Abstract from differences between object and relational world
• Complexity hidden within ORM
• Manageability of the CRUD operations for complex relationships
• Easier maintainability
Entity Framework6
Overview of EF
• Entity Framework (EF) is a standard ORM framework, part of .NET
• Provides a run-time infrastructure for managing SQL-based database
data as .NET objects
• The relational database schema is mapped to an object model
(classes and associations)
• Visual Studio has built-in tools for generating Entity Framework SQL data
mappings
• Data mappings consist of C# classes and XML
• A standard data manipulation API is provided
Different Ways EF Access Database
Developing & Testing of
ASP.Net Entity
Framework6
Develop WEP API with Entity Framework
6
• This tutorial uses ASP.NET Web API 2 with Entity Framework 6 to
create a web application that manipulates a back-end database.
• “Code First” approach will be demonstrated
Environment Setup
1. Use NuGet to search “EntityFramework”
2. Click “Install”
Environment Setup
1. Add a SQL Server Database “PracticalCoding.mdf” under “App_Data” folder
Add Models
Add Entity Framework DbContext
Identify which
connection setting
will be used
Create “DbSet” for
“Authors” &
“Books”
Inheritance
“DbContext”
Add “ConnectionStrings” Setting
1. Add “connectionStrings” in “Web.config” to link
“PracticalCoding.mdf” to “EF6DbContext”
Add WebAPI Controller
(Authors)
1
2
3
4
5
Add WebAPI Controller
(Books)
1
2
3
4
5
Code First - Migrations Features
1. “Tools”  “Library Package Manager””Package Manager Console”
2. Key in “Enable-Migrations” in “Package Manager Console”
1
2
3
Code First – Seeding Database
1. Modify “Configuration.cs”
2. Add below code to initialize (seeding) Database
Code First - Migrations Features:
Add-Migration & Update-Database
1. Key in “Add-Migration Initial” in “Package
Manager Console” and Hit “Enter”
1
2
3
3
Code First - Migrations Features:
Add-Migration & Update-Database
1. Key in “Update-Database” in “Package
Manager Console”
1
2
3
4
4
4
Explore & Test the Web API
1. Hit “F5” to run “PracticalCoding.Web”
2. Use “Fiddler2” to test below Web APIs
Demo Page
Code First – Migration Commands
• Commands Reference:
• http://coding.abel.nu/2012/03/ef-migrations-command-reference/#Update-
Database
• Most Frequent Used:
• Enable-Migrations: Enables Code First Migrations in a project.
• Add-Migration: Scaffolds a migration script for any pending model changes.
• Update-Database: Applies any pending migrations to the database.
• Get-Migrations: Displays the migrations that have been applied to the
target database.
Handling Entity Relations
• Eager Loading versus Lazy Loading
• When using EF with a relational database, it's important to understand how EF loads related
data
• Enable SQL queries that EF generates & output to Debug Trace Console
Use Fiddler2 to Get request
/api/books
• You can see that the Author property is null, even though the book contains a valid
AuthorId
• The “SELECT” statement takes from the Books tables, and does not reference Author
table
Entity Framework Data Loading
Strategy
• Very important to know how Entity Framework loading
related data
• Eager Loading
• Lazy Loading
• Explicit Loading
Entity Framework Data Loading
Strategy (Eager Loading)
• With eager loading, EF loads related entities as part of the initial
database query
• Copy “BooksController.cs” to “BooksEagerLoadController.cs”
• To perform eager loading, use the System.Data.Entity.Include extension
method as show below:
This tells EF to include the
Author data in the query
Use Fiddler2 to Get request
/api/books (Eager Load)
• The trace log shows that EF performed a join on the Book and Author tables.
Entity Framework Data Loading
Strategy (Lazy Loading)
• With lazy loading, EF automatically loads a related entity when the
navigation property for that entity is dereferenced.
• To enable lazy loading, make the navigation property virtual. For
example, in the Book class:
“virtual” tells EF to lazy
load the Author property
Entity Framework Data Loading
Strategy (Lazy Loading)
• Key in “Add-Migration AddLazyAuthorBook” in “Package Manager
Console”
• Key in “Update-Datebase” in “Package Manager Console”
1
2
3
Use Fiddler2 to Get request
/api/books (Lazy Load)
• When lazy loading is enabled, accessing the Author property on books[0] causes EF to
query the database for the author
• Lazy loading requires multiple database trips, because EF sends a query each time it
retrieves a related entity
Use Fiddler2 to Get request
/api/books (Lazy Load)
• The trace log shows that EF performed a join on the Book and Author tables.
1
2 3
4
5
6
Navigation Properties and Circular
References
• If there is “Circular References”, System will encounter problem
while serialize the model
Navigation Properties and Circular
References
• Modify “EF6DBContext” to add DbSets for CirRefBook & CirRefAuthor
• Key in “Add-Migration AddCirRefAuthorBook” in “Package Manager
Console”
• Key in “Update-Datebase” in “Package Manager Console”
• Add New WebApi Controller “CirRefBooksNGController”
Navigation Properties and Circular
References Unit Test with Fiddler2
Demo
Create Data Transfer Objects (DTOs)
• Remove circular references
• Hide particular properties that clients are not supposed to view.
• Omit some properties in order to reduce payload size.
• Flatten object graphs that contain nested objects, to make them more
convenient for clients.
• Avoid “over-posting” vulnerabilities.
• Decouple service layer from database/data storage layer.
Create Data Transfer Objects (DTOs)
Domain Entity mapping to DTO (LINQ) –
CirRefBooksLINQController.cs
POST the data via
remote WebApi using
angular $http
service object
Use LINQ to map from
Entity to DTO Object.
It works, but … just
tedious!!
Navigation Properties and Circular
References Unit Test with Fiddler2
Demo
Install “AutoMapper” 3rd Library
1. Use NuGet to search “AutoMapper”
2. Click “Install”
Domain Entity mapping to DTO (AutoMapper) –
CirRefBooksController.cs
The code is much
clean and
programmer is
happy!!
The code is much
clean and easy.
The programmer is
happy again!!
Navigation Properties and Circular
References Unit Test with Fiddler2
Demo
Highchart , AngularJS
,Web API2 , SignalR2 +
Entity Framework 6
Integration
Integration with Entity Framework
• Copy “08_AngularWithSignalR” to
“09_IntegrationWithEF6 ”
Modify EF Context for Dashboard
• Modify “EF6DbContext.cs” to add DbSet for “Chartdata” object
Create “DbSet” for
“Chartdata”
Add Entity Framework Annotation
• Modify “Models/Dashboard/Chartdata.cs” to add some EF annotation
It tell Database to
automatically generate
an Unique ID
Migration & Update Database
• Key in “Add-Migration AddChartdata” in “Package Manager Console”
• Key in “Update-Datebase” in “Package Manager Console”
1
2
3
Initial Chartdatas (Global.asax.cs)
Create New EF6DashboardRepo.cs
Switch “MemDashboardRepo” to
“EF6DashboardRepo”
• Copy “SignalRDashboardController.cs” to “EF6DashboardController.cs”
Switch our Repository
from “Memory” to
“Entity Framework”
Dispose “Entity
Framework” context
object to release
database connection
Modify Our Angular “ChartDataFactory”
• Switch angular $http communication end point to our new WebAPI url
Before After
Integration with Entity Framework6
1. Select “09_Integration/index.html” and Hit “F5” to run
2. Open Multi-Browers to see charts reflect changes whenever C/U/D
operations occurred
Demo
Next Session:
AngularJS + Highchart + Asp.Net
WebApi2 + SignalR2 + Entity
Framework6 + Redis
Ad

More Related Content

What's hot (20)

Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring Update
Gunnar Hillert
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
Gunnar Hillert
 
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff NorrisRESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
mfrancis
 
Spring Projects Infrastructure
Spring Projects InfrastructureSpring Projects Infrastructure
Spring Projects Infrastructure
Gunnar Hillert
 
Greach 2014 - Road to Grails 3.0
Greach 2014  - Road to Grails 3.0Greach 2014  - Road to Grails 3.0
Greach 2014 - Road to Grails 3.0
graemerocher
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
Maarten Balliauw
 
S2GX 2012 - Spring Projects Infrastructure
S2GX 2012 - Spring Projects InfrastructureS2GX 2012 - Spring Projects Infrastructure
S2GX 2012 - Spring Projects Infrastructure
Gunnar Hillert
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
Matthew Groves
 
Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internals
carlo-rtr
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
Ayush Mishra
 
Apache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawaniApache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawani
Bhawani N Prasad
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
Dimitar Damyanov
 
Hazelcast
HazelcastHazelcast
Hazelcast
Jeevesh Pandey
 
Riding rails for 10 years
Riding rails for 10 yearsRiding rails for 10 years
Riding rails for 10 years
jduff
 
Esri Dev Summit 2009 Rest and Mvc Final
Esri Dev Summit 2009 Rest and Mvc FinalEsri Dev Summit 2009 Rest and Mvc Final
Esri Dev Summit 2009 Rest and Mvc Final
guestcd4688
 
Chef Actions: Delightful near real-time activity tracking!
Chef Actions: Delightful near real-time activity tracking!Chef Actions: Delightful near real-time activity tracking!
Chef Actions: Delightful near real-time activity tracking!
James Casey
 
Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018
DocFluix, LLC
 
Going Headless with Craft CMS 3.3
Going Headless with Craft CMS 3.3Going Headless with Craft CMS 3.3
Going Headless with Craft CMS 3.3
JustinHolt20
 
Apache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDBApache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDB
MongoDB
 
Oozie @ Riot Games
Oozie @ Riot GamesOozie @ Riot Games
Oozie @ Riot Games
Matt Goeke
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring Update
Gunnar Hillert
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
Gunnar Hillert
 
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff NorrisRESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
mfrancis
 
Spring Projects Infrastructure
Spring Projects InfrastructureSpring Projects Infrastructure
Spring Projects Infrastructure
Gunnar Hillert
 
Greach 2014 - Road to Grails 3.0
Greach 2014  - Road to Grails 3.0Greach 2014  - Road to Grails 3.0
Greach 2014 - Road to Grails 3.0
graemerocher
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
Maarten Balliauw
 
S2GX 2012 - Spring Projects Infrastructure
S2GX 2012 - Spring Projects InfrastructureS2GX 2012 - Spring Projects Infrastructure
S2GX 2012 - Spring Projects Infrastructure
Gunnar Hillert
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
Matthew Groves
 
Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internals
carlo-rtr
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
Ayush Mishra
 
Apache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawaniApache spark with akka couchbase code by bhawani
Apache spark with akka couchbase code by bhawani
Bhawani N Prasad
 
Riding rails for 10 years
Riding rails for 10 yearsRiding rails for 10 years
Riding rails for 10 years
jduff
 
Esri Dev Summit 2009 Rest and Mvc Final
Esri Dev Summit 2009 Rest and Mvc FinalEsri Dev Summit 2009 Rest and Mvc Final
Esri Dev Summit 2009 Rest and Mvc Final
guestcd4688
 
Chef Actions: Delightful near real-time activity tracking!
Chef Actions: Delightful near real-time activity tracking!Chef Actions: Delightful near real-time activity tracking!
Chef Actions: Delightful near real-time activity tracking!
James Casey
 
Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018
DocFluix, LLC
 
Going Headless with Craft CMS 3.3
Going Headless with Craft CMS 3.3Going Headless with Craft CMS 3.3
Going Headless with Craft CMS 3.3
JustinHolt20
 
Apache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDBApache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDB
MongoDB
 
Oozie @ Riot Games
Oozie @ Riot GamesOozie @ Riot Games
Oozie @ Riot Games
Matt Goeke
 

Similar to 04 integrate entityframework (20)

70487.pdf
70487.pdf70487.pdf
70487.pdf
Karen Benoit
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
Igor Talevski
 
ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4
James Johnson
 
MVC and Entity Framework 4
MVC and Entity Framework 4MVC and Entity Framework 4
MVC and Entity Framework 4
James Johnson
 
Spring - a framework written by developers
Spring - a framework written by developersSpring - a framework written by developers
Spring - a framework written by developers
MarcioSoaresPereira1
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
IBM File Net P8
IBM File Net P8IBM File Net P8
IBM File Net P8
Mohammed El Rafie Tarabay
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
mohamed elshafey
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
Yochay Kiriaty
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
Jibran Rasheed Khan
 
Entity framework core v3 from sql to no sql
Entity framework core v3 from sql to no sqlEntity framework core v3 from sql to no sql
Entity framework core v3 from sql to no sql
Andrea Tosato
 
AvalancheProject2012
AvalancheProject2012AvalancheProject2012
AvalancheProject2012
fishetra
 
Machine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE FukuokaMachine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE Fukuoka
LINE Corporation
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
Ben Steinhauser
 
Entity Framework Core (EF Core) Power Point Slide Show
Entity Framework Core (EF Core) Power Point Slide ShowEntity Framework Core (EF Core) Power Point Slide Show
Entity Framework Core (EF Core) Power Point Slide Show
hammadali341730
 
Basics Of Introduction to ASP.NET Core.pptx
Basics Of Introduction to ASP.NET Core.pptxBasics Of Introduction to ASP.NET Core.pptx
Basics Of Introduction to ASP.NET Core.pptx
1rajeev1mishra
 
ASP.net web api Power Point Presentation
ASP.net web api Power Point PresentationASP.net web api Power Point Presentation
ASP.net web api Power Point Presentation
BefastMeetingMinutes
 
Frame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine LearningFrame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine Learning
David Stein
 
Xamarin.Forms Bootcamp
Xamarin.Forms BootcampXamarin.Forms Bootcamp
Xamarin.Forms Bootcamp
Mike Melusky
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
Igor Talevski
 
ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4
James Johnson
 
MVC and Entity Framework 4
MVC and Entity Framework 4MVC and Entity Framework 4
MVC and Entity Framework 4
James Johnson
 
Spring - a framework written by developers
Spring - a framework written by developersSpring - a framework written by developers
Spring - a framework written by developers
MarcioSoaresPereira1
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
mohamed elshafey
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
Yochay Kiriaty
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
Jibran Rasheed Khan
 
Entity framework core v3 from sql to no sql
Entity framework core v3 from sql to no sqlEntity framework core v3 from sql to no sql
Entity framework core v3 from sql to no sql
Andrea Tosato
 
AvalancheProject2012
AvalancheProject2012AvalancheProject2012
AvalancheProject2012
fishetra
 
Machine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE FukuokaMachine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE Fukuoka
LINE Corporation
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
Ben Steinhauser
 
Entity Framework Core (EF Core) Power Point Slide Show
Entity Framework Core (EF Core) Power Point Slide ShowEntity Framework Core (EF Core) Power Point Slide Show
Entity Framework Core (EF Core) Power Point Slide Show
hammadali341730
 
Basics Of Introduction to ASP.NET Core.pptx
Basics Of Introduction to ASP.NET Core.pptxBasics Of Introduction to ASP.NET Core.pptx
Basics Of Introduction to ASP.NET Core.pptx
1rajeev1mishra
 
ASP.net web api Power Point Presentation
ASP.net web api Power Point PresentationASP.net web api Power Point Presentation
ASP.net web api Power Point Presentation
BefastMeetingMinutes
 
Frame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine LearningFrame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine Learning
David Stein
 
Xamarin.Forms Bootcamp
Xamarin.Forms BootcampXamarin.Forms Bootcamp
Xamarin.Forms Bootcamp
Mike Melusky
 
Ad

More from Erhwen Kuo (17)

Datacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheusDatacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheus
Erhwen Kuo
 
Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03
Erhwen Kuo
 
Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02
Erhwen Kuo
 
Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01
Erhwen Kuo
 
Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)
Erhwen Kuo
 
Cncf k8s_network_02
Cncf k8s_network_02Cncf k8s_network_02
Cncf k8s_network_02
Erhwen Kuo
 
Cncf k8s_network_part1
Cncf k8s_network_part1Cncf k8s_network_part1
Cncf k8s_network_part1
Erhwen Kuo
 
Cncf explore k8s_api_go
Cncf explore k8s_api_goCncf explore k8s_api_go
Cncf explore k8s_api_go
Erhwen Kuo
 
CNCF explore k8s api using java client
CNCF explore k8s api using java clientCNCF explore k8s api using java client
CNCF explore k8s api using java client
Erhwen Kuo
 
CNCF explore k8s_api
CNCF explore k8s_apiCNCF explore k8s_api
CNCF explore k8s_api
Erhwen Kuo
 
Cncf Istio introduction
Cncf Istio introductionCncf Istio introduction
Cncf Istio introduction
Erhwen Kuo
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)
Erhwen Kuo
 
啟動你的AI工匠魂
啟動你的AI工匠魂啟動你的AI工匠魂
啟動你的AI工匠魂
Erhwen Kuo
 
Realtime analytics with Flink and Druid
Realtime analytics with Flink and DruidRealtime analytics with Flink and Druid
Realtime analytics with Flink and Druid
Erhwen Kuo
 
Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]
Erhwen Kuo
 
Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]
Erhwen Kuo
 
Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]
Erhwen Kuo
 
Datacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheusDatacon 2019-ksql-kubernetes-prometheus
Datacon 2019-ksql-kubernetes-prometheus
Erhwen Kuo
 
Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03Cncf k8s Ingress Example-03
Cncf k8s Ingress Example-03
Erhwen Kuo
 
Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02Cncf k8s Ingress Example-02
Cncf k8s Ingress Example-02
Erhwen Kuo
 
Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01Cncf k8s Ingress Example-01
Cncf k8s Ingress Example-01
Erhwen Kuo
 
Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)Cncf k8s_network_03 (Ingress introduction)
Cncf k8s_network_03 (Ingress introduction)
Erhwen Kuo
 
Cncf k8s_network_02
Cncf k8s_network_02Cncf k8s_network_02
Cncf k8s_network_02
Erhwen Kuo
 
Cncf k8s_network_part1
Cncf k8s_network_part1Cncf k8s_network_part1
Cncf k8s_network_part1
Erhwen Kuo
 
Cncf explore k8s_api_go
Cncf explore k8s_api_goCncf explore k8s_api_go
Cncf explore k8s_api_go
Erhwen Kuo
 
CNCF explore k8s api using java client
CNCF explore k8s api using java clientCNCF explore k8s api using java client
CNCF explore k8s api using java client
Erhwen Kuo
 
CNCF explore k8s_api
CNCF explore k8s_apiCNCF explore k8s_api
CNCF explore k8s_api
Erhwen Kuo
 
Cncf Istio introduction
Cncf Istio introductionCncf Istio introduction
Cncf Istio introduction
Erhwen Kuo
 
TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)TDEA 2018 Kafka EOS (Exactly-once)
TDEA 2018 Kafka EOS (Exactly-once)
Erhwen Kuo
 
啟動你的AI工匠魂
啟動你的AI工匠魂啟動你的AI工匠魂
啟動你的AI工匠魂
Erhwen Kuo
 
Realtime analytics with Flink and Druid
Realtime analytics with Flink and DruidRealtime analytics with Flink and Druid
Realtime analytics with Flink and Druid
Erhwen Kuo
 
Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]
Erhwen Kuo
 
Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]
Erhwen Kuo
 
Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]
Erhwen Kuo
 
Ad

Recently uploaded (20)

How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 

04 integrate entityframework

  • 1. AngularJS + Asp.Net Web Api + Signalr + EF6:前後端整合篇 開發技巧實戰系列(4/6) - Web 前後端整合 講師: 郭二文 ([email protected])
  • 2. Document, Source code & Training Video (4/6) • https://github.com/erhwenkuo/PracticalCoding
  • 3. Previous Training Session Document, Source code & Training Video (3/6) • https://www.youtube.com/watch?v=z UXYuCicBDc&feature=youtu.be • http://www.slideshare.net/erhwenku o/03-integrate-webapisignalr
  • 4. Agenda • ORM Technologies – Basic Concepts • Entity Framework - Overview • Developing & Testing of ASP.Net EF6 • Highchart , AngularJS ,Web API2 , SignalR2 + EF6 Integration
  • 5. ORM Technologies – Basic Concepts
  • 6. Introduction to Object-Relational Mapping (ORM) • Object-Relational Mapping (ORM) is a programming technique for automatic mapping and converting data • Between relational database tables and object-oriented classes and objects • ORM creates a "virtual object database“ • Which can be used from within the programming language, e.g. C# or Java • ORM frameworks automate the ORM process • A.k.a. object-relational persistence frameworks
  • 7. Functionality of ORM • ORM frameworks typically provide the following functionality: • Creating object model by database schema • Creating database schema by object model • Querying data by object-oriented API • Data manipulation operations • CRUD – create, retrieve, update, delete • ORM frameworks automatically generate SQL to perform the requested data operations
  • 8. ORM Mapping - Example Relational database schema ORM Entities (C# Classes) ORM Framework
  • 9. ORM Advantages • Developer productivity • Writing less code • Abstract from differences between object and relational world • Complexity hidden within ORM • Manageability of the CRUD operations for complex relationships • Easier maintainability
  • 11. Overview of EF • Entity Framework (EF) is a standard ORM framework, part of .NET • Provides a run-time infrastructure for managing SQL-based database data as .NET objects • The relational database schema is mapped to an object model (classes and associations) • Visual Studio has built-in tools for generating Entity Framework SQL data mappings • Data mappings consist of C# classes and XML • A standard data manipulation API is provided
  • 12. Different Ways EF Access Database
  • 13. Developing & Testing of ASP.Net Entity Framework6
  • 14. Develop WEP API with Entity Framework 6 • This tutorial uses ASP.NET Web API 2 with Entity Framework 6 to create a web application that manipulates a back-end database. • “Code First” approach will be demonstrated
  • 15. Environment Setup 1. Use NuGet to search “EntityFramework” 2. Click “Install”
  • 16. Environment Setup 1. Add a SQL Server Database “PracticalCoding.mdf” under “App_Data” folder
  • 18. Add Entity Framework DbContext Identify which connection setting will be used Create “DbSet” for “Authors” & “Books” Inheritance “DbContext”
  • 19. Add “ConnectionStrings” Setting 1. Add “connectionStrings” in “Web.config” to link “PracticalCoding.mdf” to “EF6DbContext”
  • 22. Code First - Migrations Features 1. “Tools”  “Library Package Manager””Package Manager Console” 2. Key in “Enable-Migrations” in “Package Manager Console” 1 2 3
  • 23. Code First – Seeding Database 1. Modify “Configuration.cs” 2. Add below code to initialize (seeding) Database
  • 24. Code First - Migrations Features: Add-Migration & Update-Database 1. Key in “Add-Migration Initial” in “Package Manager Console” and Hit “Enter” 1 2 3 3
  • 25. Code First - Migrations Features: Add-Migration & Update-Database 1. Key in “Update-Database” in “Package Manager Console” 1 2 3 4 4 4
  • 26. Explore & Test the Web API 1. Hit “F5” to run “PracticalCoding.Web” 2. Use “Fiddler2” to test below Web APIs Demo Page
  • 27. Code First – Migration Commands • Commands Reference: • http://coding.abel.nu/2012/03/ef-migrations-command-reference/#Update- Database • Most Frequent Used: • Enable-Migrations: Enables Code First Migrations in a project. • Add-Migration: Scaffolds a migration script for any pending model changes. • Update-Database: Applies any pending migrations to the database. • Get-Migrations: Displays the migrations that have been applied to the target database.
  • 28. Handling Entity Relations • Eager Loading versus Lazy Loading • When using EF with a relational database, it's important to understand how EF loads related data • Enable SQL queries that EF generates & output to Debug Trace Console
  • 29. Use Fiddler2 to Get request /api/books • You can see that the Author property is null, even though the book contains a valid AuthorId • The “SELECT” statement takes from the Books tables, and does not reference Author table
  • 30. Entity Framework Data Loading Strategy • Very important to know how Entity Framework loading related data • Eager Loading • Lazy Loading • Explicit Loading
  • 31. Entity Framework Data Loading Strategy (Eager Loading) • With eager loading, EF loads related entities as part of the initial database query • Copy “BooksController.cs” to “BooksEagerLoadController.cs” • To perform eager loading, use the System.Data.Entity.Include extension method as show below: This tells EF to include the Author data in the query
  • 32. Use Fiddler2 to Get request /api/books (Eager Load) • The trace log shows that EF performed a join on the Book and Author tables.
  • 33. Entity Framework Data Loading Strategy (Lazy Loading) • With lazy loading, EF automatically loads a related entity when the navigation property for that entity is dereferenced. • To enable lazy loading, make the navigation property virtual. For example, in the Book class: “virtual” tells EF to lazy load the Author property
  • 34. Entity Framework Data Loading Strategy (Lazy Loading) • Key in “Add-Migration AddLazyAuthorBook” in “Package Manager Console” • Key in “Update-Datebase” in “Package Manager Console” 1 2 3
  • 35. Use Fiddler2 to Get request /api/books (Lazy Load) • When lazy loading is enabled, accessing the Author property on books[0] causes EF to query the database for the author • Lazy loading requires multiple database trips, because EF sends a query each time it retrieves a related entity
  • 36. Use Fiddler2 to Get request /api/books (Lazy Load) • The trace log shows that EF performed a join on the Book and Author tables. 1 2 3 4 5 6
  • 37. Navigation Properties and Circular References • If there is “Circular References”, System will encounter problem while serialize the model
  • 38. Navigation Properties and Circular References • Modify “EF6DBContext” to add DbSets for CirRefBook & CirRefAuthor • Key in “Add-Migration AddCirRefAuthorBook” in “Package Manager Console” • Key in “Update-Datebase” in “Package Manager Console” • Add New WebApi Controller “CirRefBooksNGController”
  • 39. Navigation Properties and Circular References Unit Test with Fiddler2 Demo
  • 40. Create Data Transfer Objects (DTOs) • Remove circular references • Hide particular properties that clients are not supposed to view. • Omit some properties in order to reduce payload size. • Flatten object graphs that contain nested objects, to make them more convenient for clients. • Avoid “over-posting” vulnerabilities. • Decouple service layer from database/data storage layer.
  • 41. Create Data Transfer Objects (DTOs)
  • 42. Domain Entity mapping to DTO (LINQ) – CirRefBooksLINQController.cs POST the data via remote WebApi using angular $http service object Use LINQ to map from Entity to DTO Object. It works, but … just tedious!!
  • 43. Navigation Properties and Circular References Unit Test with Fiddler2 Demo
  • 44. Install “AutoMapper” 3rd Library 1. Use NuGet to search “AutoMapper” 2. Click “Install”
  • 45. Domain Entity mapping to DTO (AutoMapper) – CirRefBooksController.cs The code is much clean and programmer is happy!! The code is much clean and easy. The programmer is happy again!!
  • 46. Navigation Properties and Circular References Unit Test with Fiddler2 Demo
  • 47. Highchart , AngularJS ,Web API2 , SignalR2 + Entity Framework 6 Integration
  • 48. Integration with Entity Framework • Copy “08_AngularWithSignalR” to “09_IntegrationWithEF6 ”
  • 49. Modify EF Context for Dashboard • Modify “EF6DbContext.cs” to add DbSet for “Chartdata” object Create “DbSet” for “Chartdata”
  • 50. Add Entity Framework Annotation • Modify “Models/Dashboard/Chartdata.cs” to add some EF annotation It tell Database to automatically generate an Unique ID
  • 51. Migration & Update Database • Key in “Add-Migration AddChartdata” in “Package Manager Console” • Key in “Update-Datebase” in “Package Manager Console” 1 2 3
  • 54. Switch “MemDashboardRepo” to “EF6DashboardRepo” • Copy “SignalRDashboardController.cs” to “EF6DashboardController.cs” Switch our Repository from “Memory” to “Entity Framework” Dispose “Entity Framework” context object to release database connection
  • 55. Modify Our Angular “ChartDataFactory” • Switch angular $http communication end point to our new WebAPI url Before After
  • 56. Integration with Entity Framework6 1. Select “09_Integration/index.html” and Hit “F5” to run 2. Open Multi-Browers to see charts reflect changes whenever C/U/D operations occurred Demo
  • 57. Next Session: AngularJS + Highchart + Asp.Net WebApi2 + SignalR2 + Entity Framework6 + Redis

Editor's Notes

  • #2: 開發技巧實戰 1. AngularJS入門篇 2. AngularJS + HighChart:完美網頁圖表整合篇 3. AngularJS + Asp.Net WebApi 2 +SignalR:前後端整合篇 4. AngularJS + Asp.Net WebApi 2+ SignalR + Entity Framework 6 (ORM):前後端整合篇 5. AngularJS + Asp.Net WebApi 2+ SignalR +Entity Framework 6 (ORM) + Redis (Nosql):前後端整合篇 6. AngularJS + Asp.Net WebApi 2+ SignalR +Entity Framework 6 (ORM) + Redis (Nosql) + Elasticsearch (全文檢索):前後端整合篇
  • #4: 本章節的內容會延續前一個Session的知識與內容, 如果對前一章節不熟悉的話, 可以在Yoube或Slideshare找到文件與教學錄影