Are complex, presumptive Architecture systems that client got
to work, usually with some degree of technical debt Contain certain
key characteristics (some exist, others desired): Data Aware
Transactional Concurrent Performant Compliant Fault-Tolerant (again
desired) Usable (almost always desired)
Slide 6
Slide 7
Workflow
Slide 8
Slide 9
Slide 10
10 What is a Model? Database Tables Customer Entity Classes
Model/Mappings Addresses Order Product Phone Customer Order US
Product UK Product FK Product
Slide 11
Slide 12
Slide 13
13 Improve Model By Refactoring Customer Customer Context
Mappings Addresses Order Product Phone Customer US Product UK
Product FK Product Intl Order Category Supplier Order Intl Order
Supplier Category Customer Order Context Abbreviated customer table
with Read-Only Fields
Slide 14
Slide 15
Slide 16
Context Object EF scans context for changes Wraps all updates
as an Unit of Work
Slide 17
Default EF Transaction Behavior Maximizing Transaction Control
- BeginTransaction API Sharing transaction with EF context -
UseTransaction API
Slide 18
Slide 19
Slide 20
Same Record Whose changes are saved ?
Slide 21
modelBuilder.Entity ().Property(x =>
x.RowVersion).IsConcurrencyToken().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
modelBuilder.Entity ().Property(x =>
x.RowVersion).IsConcurrencyToken().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
exec sp_executesql N'UPDATE [dbo].[Phones] SET [Type] = @0 WHERE
(([Id] = @1) AND ([RowVersion] = @2)) SELECT [RowVersion] FROM
[dbo].[Phones] WHERE @@ROWCOUNT > 0 AND [Id] = @1', N'@0
nchar(10),@1 int,@2
binary(8)',@0=N'Home',@1=2894,@2=0x0000000000004656 exec
sp_executesql N'UPDATE [dbo].[Phones] SET [Type] = @0 WHERE (([Id]
= @1) AND ([RowVersion] = @2)) SELECT [RowVersion] FROM
[dbo].[Phones] WHERE @@ROWCOUNT > 0 AND [Id] = @1', N'@0
nchar(10),@1 int,@2
binary(8)',@0=N'Home',@1=2894,@2=0x0000000000004656 You EF
Slide 22
Maintains three copies of data
Slide 23
Custom Concurrency Algorithm: Merging Results
Slide 24
Slide 25
Slide 26
Slide 27
DAL Database UI Entity Framework Query Execution Engine Request
SQL QueryLINQ Query Untyped SQL Result Set Strongly-Typed Entity
Objects Response EF materializes untyped SQL result set into
strongly-typed entities Developers write strongly- typed LINQ
expression EF transforms to provider- specific SQL and
executes
EF v1EF 4EF 4.1, 4.2EF 4.3EF 5EF 6 To leverage, must implement
EF 5+ and.NET Framework 4.5+
Slide 38
Slide 39
LINQ Query Create Hash for Query Hash Exist in Cache? Add
Parameters to SQL DB
Slide 40
Slide 41
Slide 42
Slide 43
Having a friend buy your coffee? Yea, its kind of like that.
MSDN Subscribers get up to $150/mo in Azure credits. Stop by the
Developer Platform and Tools booth and visit the MSDN Subscriptions
station to activate your benefits and receive a gift!
http://aka.ms/msdn_teched 3 Steps to New Gear! With Application
Insights
Slide 44
Microsoft Engineering Stories Visual Studio Industry Partner
Program Visual Studio | Integrate http://www.visualstudio.com