Download presentation
Presentation is loading. Please wait.
Published byMorgan Walsh Modified over 9 years ago
5
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)
7
Workflow
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
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
16
Context Object EF scans context for changes Wraps all updates as an Unit of Work
17
Default EF Transaction Behavior Maximizing Transaction Control - BeginTransaction API Sharing transaction with EF context - UseTransaction API
20
Same Record Whose changes are saved ?
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
22
Maintains three copies of data
23
Custom Concurrency Algorithm: Merging Results
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
30
Profile LINQ Query with SQL Profiler
32
Disregard Performance at your own Peril!
34
SaveChangesAsync()FirstOrDefaultAsync()ToListAsync() LoadAsync()SumAsync()MaxAsync ExecuteSqlCommandAsync()AnyAsync()FindAsync()
35
Asynchronous Queries
37
EF v1EF 4EF 4.1, 4.2EF 4.3EF 5EF 6 To leverage, must implement EF 5+ and.NET Framework 4.5+
39
LINQ Query Create Hash for Query Hash Exist in Cache? Add Parameters to SQL DB
43
Having a friend buy your coffee? Yea, it’s 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
44
Microsoft Engineering Stories Visual Studio Industry Partner Program Visual Studio | Integrate http://www.visualstudio.com
47
www.microsoft.com/learning http://microsoft.com/msdn http://microsoft.com/technet http://channel9.msdn.com/Events/TechEd
54
var customers = ctx.Customers.AsNoTracking().ToList();
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.