Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 192 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
192
Dung lượng
5,94 MB
Nội dung
[...]... Database First workflow, you reverse engineer from a database and then let a code generator create the classes The CodeFirst workflow begins with you coding your classes and then optionally letting CodeFirst create a database for you Getting CodeFirst to Developers in Between NET Releases CodeFirst was not ready in time to be released in NET 4 Rather than waiting for the NET 5 release to bring Code First. .. type of modeling is called Code FirstCodeFirst lets you define your domain model with code rather than using an XML-based EDMX file Even though Model First and Database First use code generation to provide classes for you to work with, many developers simply did not want to work with a designer nor have their classes generated for them They just wanted to write code In CodeFirst you begin by defining... you choose to go with a designer or to use the code- based modeling is entirely your decision Figure 1-1 lays out the different options you have for modeling with Entity Framework 2 | Chapter 1: Welcome to CodeFirst Figure 1-1 Modeling workflow options Microsoft refers to the Database First, Model First, and CodeFirst options as workflows (e.g., the CodeFirst workflow) That’s because each of those... updates to the Entity Framework NuGet package Writing the Code FirstCodeFirst is aptly named: the code comes first, the rest follows Let’s take a look at the basic default functionality without worrying about all of the possible scenarios you might need to support The rest of the book is dedicated to that We don’t expect you to recreate the sample code shown in this first chapter The code samples are... First to developers, Microsoft made CodeFirst available in an out-of-band release, referred to as Entity Framework 4.1, in April 2011 The version number will increment as subsequent updates are released Entity Framework 4.2 was released in October 2011 and replaces Entity Framework 4.1 as the release that included CodeFirst The core Entity Framework API, System.Data .Entity. dll, is still part of the... classes One of the big advantages of CodeFirst is that your classes become the model This means any changes to the model only need to be made in one place—your POCO classes Code First, Database First, and Model First are all just ways of building an Entity Data Model that can be used with Entity Framework to perform data access Once the model has been built, the Entity Framework runtime behaves the... structure that Entity Framework should expect in the database when you have classes that inherit from each other This could be very limiting if CodeFirst relied solely on convention to work with your classes But CodeFirst is not determined to force you to design your classes to meet its needs Instead, the conventions exist to enable Code First to automatically handle some Writing the CodeFirst | 5 common... a look at “Reverse Engineer CodeFirst on page 173 (Chapter 8) What CodeFirst Does Not Support CodeFirst is a relatively new addition to Entity Framework and there are a few features that it currently does not support The EF team has indicated that they plan to add support for most of these in future releases Database migrations At the time of writing this book, Code First does not yet support database... provider–independent CodeFirst does not support either of these features yet Multiple Entity Sets per Type (MEST) CodeFirst does not support the Multiple Entity Sets per Type (MEST) feature MEST allows you to use the same class in two different sets that map to two different tables This is a more obscure Entity Framework feature that is rarely used The EF team has said that, in an effort to keep the Code First. .. business model of ProgrammingEntity Framework, software applications built for a company called Break Away Geek Adventures Look for a second short book titled Programming Entity Framework: DbContext, which will focus on DbContext, DbSet, Validation API, and using the features that are also part of the Entity Framework NuGet package Learning from This Book | 15 CHAPTER 2 Your First Look at CodeFirst If you’ve .
Programming Entity Framework:
Code First
Julia Lerman and Rowan Miller
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo
Programming Entity Framework:. . . . 171
Code First Migrations 171
Entity Framework Power Tools 173
Reverse Engineer Code First 173
Viewing a Code First Model 174
Optimize Entity Data