آموزشگاه برنامه نویسی تحلیل داده
آموزشگاه برنامه نویسی تحلیل داده
آموزشگاه برنامه نویسی تحلیل داده
آموزشگاه برنامه نویسی تحلیل داده

Programming Entity Framework- Code First

  • عنوان :

    Programming Entity Framework- Code First

  • نویسنده : Julia Lerman and Rowan Miller

 

1. Welcome to Code First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Modeling with EF Before Code First 1
Inception of Code First 2
Getting Code First to Developers in Between .NET Releases 3
Writing the Code…First 4
Managing Objects with DbContext 6
Using the Data Layer and Domain Classes 7
Getting from Classes to a Database 8
Working with Configuration 10
Configuring with Data Annotations 10
Configuring with the Fluent API 11
Creating or Pointing to a Database 12
What Code First Does Not Support 12
Choosing Code First 13
Learning from This Book 15
2. Your First Look at Code First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Introducing EF to the Domain Classes 18
Putting the Pieces Together in an Example 18
Convention for Table, Schema, and Column Names 22
Convention for Keys 23
Convention for String Properties 23
Convention for Byte Array 24
Convention for Booleans 24
Convention for One-to-Many Relationships 24
Overriding Convention with Configurations 25
Configuring with Data Annotations 25
Understanding How Model Changes Impact Database Initialization 27
Data Annotations and Validation-Aware UIs 30
Configuring Code First with the Fluent API 31
Organizing Fluent Configurations 33
Summary 35
3. Using Conventions and Configurations for Property Attributes . . . . . . . . . . . . . . . . 37
Working with Property Attributes in Code First 37
Length 38
Data Type 38
Nullability and the Required Configuration 39
Mapping Keys 40
Code First Convention Response to Unconventional Key Properties 40
Configuring the Key with Data Annotations 41
Using HasKey to Configure a Key Property in the Fluent API 41
Configuring Database-Generated Properties 42
Configuring Database-Generated Options with Data Annotations 43
Configuring Database-Generated Options with the Fluent API 46
Configuring TimeStamp/RowVersion Fields for Optimistic Concurrency 46
Code First Convention and TimeStamp fields 47
Using Data Annotations to Configure TimeStamp 47
Configuring TimeStamp/RowVersion with Fluent API 49
Configuring Non-Timestamp Fields for Concurrency 49
Configuring for Optimistic Concurrency with Data Annotations 50
Configuring for Optimistic Concurrency with Fluent API 51
Mapping to Non-Unicode Database Types 51
Affecting the Precision and Scale of Decimals 52
Convention for Precision and Scale 52
Data Annotations for Precision and Scale 52
Fluent Configuration for Precision and Scale 52
Working with Complex Types in Code First 53
Defining Complex Types by Convention 54
Configuring Unconventional Complex Types 56
Working with More Complicated Complex Types 57
Configuring Properties of Complex Types 58
Configuring Complex Types with Data Annotations 58
Configuring Complex Type Properties with the Fluent API 59
Summary 60
4. Using Convention and Configuration for Relationships . . . . . . . . . . . . . . . . . . . . . . . 61
Working with Multiplicity 63
Configuring Multiplicity with Data Annotations 63
Configuring Multiplicity with the Fluent API 64
Working with Foreign Keys 66
Specifying Unconventionally Named Foreign Keys 68
Working with Inverse Navigation Properties 71
Working with Cascade Delete 73
Turning On or Off Client-Side Cascade Delete with Fluent Configurations
76
Setting Cascade Delete Off in Scenarios That Are Not Supported by the
Database 78
Exploring Many-to-Many Relationships 78
Working with Relationships that Have Unidirectional Navigation 81
Working with One-to-One Relationships 84
Configuring One-to-One Relationships When Both Ends Are Required 87
Summary 88
5. Using Conventions and Configurations for Database Mappings . . . . . . . . . . . . . . . . 91
Mapping Class Name to Database Table and Schema Name 91
Configuring Table and Schema Name with Data Annotations 92
Configuring Table and Schema Name with the Fluent API 93
Mapping Property Names to Database Columns 93
Modifying the Default Column Name with Data Annotations 93
Modifying the Default Column Name with the Fluent API 93
Affecting Column Names for Complex Types 94
Allowing Multiple Entities to Map to a Single Table:
aka Table Splitting 95
Mapping to a Common Table using Data Annotations 96
Splitting a Table Using the Fluent API 99
Mapping a Single Entity Across Multiple Tables 99
Controlling Which Types Get Mapped to the Database 104
Preventing Types from Being Included in the Model 105
Understanding Property Mapping and Accessibility 106
Scalar Property Mapping 106
Accessibility of Properties, Getters, and Setters 106
Preventing Properties from Being Included in the Model 108
Data Annotations for Ignoring a Property 109
Fluent Configuration for Ignoring a Property 109
Mapping Inheritance Hierarchies 109
Working with Code First’s Default Inheritance: Table Per Hierarchy
(TPH) 109
Customizing the TPH Discriminator Field with the Fluent API 112
Configuring Table Per Type (TPT) Hierarchy 113
Configuring for Table Per Concrete Type (TPC) Inheritance 115
Avoiding Mapping Exceptions with TPC 116
Working with Abstract Base Classes 119
Mapping Relationships 123
Controlling Foreign Keys Included in Your Class 123
Controlling Foreign Keys That Are Created by Code First 124
Controlling Many-to-Many Join Tables 125
Summary 127
6. Controlling Database Location, Creation Process, and Seed Data . . . . . . . . . . . . . . 129
Controlling the Database Location 129
Controlling Database Location with a Configuration File 130
Controlling Database Name with DbContext Constructor 131
Controlling Connection String Name with DbContext Constructor 132
Reusing Database Connections 133
Controlling Database Location with Connection Factories 134
Working with Database Initialization 139
Controlling When Database Initialization Occurs 139
Switching Off Database Initialization Completely 141
Database Initializers Included in Entity Framework 141
Creating a Custom Database Initializer 144
Setting Database Initializers from a Configuration File 147
Using Database Initializers to Seed Data 149
Using Database Initialization to Further Affect Database Schema 151
Summary 152
7. Advanced Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Mapping to Nontable Database Objects 153
Mapping to Updatable Views 154
Using Views to Populate Objects 154
Using Views to Populate Nonmodel Objects 155
Working with Stored Procedures 156
Removing Conventions 157
Taking Control of Model Caching 159
Understanding Model Caching 160
Overriding Default Model Caching 160
Working with the EdmMetadata Table 165
Coding Against EdmMetadata 165
Preventing Code First from Creating and Seeking EdmMetadata 166
Using Code First with ObjectContext 167
Summary 169
8. What’s Coming Next for Code First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Code First Migrations 171
Entity Framework Power Tools 173
Reverse Engineer Code First 173
Viewing a Code First Model 174
Optimize Entity Data Model 175
  • 23650
  •    777
  • تاریخ ارسال:   1394/07/27

دانلود رایگان کتاب ( PDF )  دانشجویان گرامی اگر این مطلب برای شما مفید بود لطفا ما را در GooglePlus محبوب کنید
رمز عبور: tahlildadeh.com یا www.tahlildadeh.com

لطفا به این مطلب امتیاز دهید
ثبت امتیاز 0
0       0
ارسال دیدگاه نظرات کاربران
شماره موبایل دیدگاه
عنوان پست الکترونیک

ارسال

تمامی حقوق این سایت متعلق به آموزشگاه تحلیل داده می باشد .