Preface

I have been writing applications on the Microsoft platform for almost 2 decades. Many, if not all of them, use databases to persist user data. I have used many technologies to access data, starting with ADO.NET. Object Relational Mapping (ORM) tools, have many advantages over ADO.NET. They allow developers to write data access code faster and safer. ORM tools have been designed to solve impedance mismatch problems between object-oriented programming and relational databases. Microsoft's Entity Framework is the company's answer to the demand for an ORM from .NET developers. This book is the guide that will help you acquire the necessary skills to program your applications using Entity Framework.

This book centers on the Code-First approach with Entity Framework, which has become the most common way of using the technology. Code-First allows developers to control the entire data access layer of their applications from the .NET code. This approach simplifies and streamlines the entire application development life cycle, keeping developers coding inside Visual Studio, the only tool they need to use Entity Framework.

The books starts with the basic concepts of defining the database structure via C# and VB.NET code, then progresses to full data access. Chapters cover create, read, update, and delete operations (CRUD) with Entity Framework. It also shows how to update the Relational Database Management System, (RDBMS) structure, via the migrations API. It explores aspects of data access in both .NET languages using the Languages INtegration Query (LINQ), API. Because of Microsoft's continuous commitment to both C# and VB.NET, the book contains examples in both languages in every chapter.

I have been using Entity Framework since 2008, and I felt that I had the necessary experience to write a book on the subject. I spoke on the topic on many conferences and events and saw tremendous interest in creating a concise guide to Entity Framework. This was one of my primary motivations in creating a shorter textbook. I read many technical books while working in the industry, and I myself, at times, had trouble maintaining the focus while reading 800-page technical books. They definitely have a place in the industry and are very useful. However, I feel they are intimidating for the developers who are just getting started with a particular technology. My hope is that this book will get you going quickly on the new topic and have you writing data access code in a few hours. You should be able to master the foundation behind Entity Framework with this book quickly and easily.

What this book covers

Chapter 1, Introducing Entity Framework, gives us an understanding of what the, Object Relational Mapping (ORM) technology brings to developers. You learn the history of Entity Framework as an example of an ORM. We study the architecture behind the Entity Framework technology.

Chapter 2, Your First Entity Framework Application, teaches us how to create our first project that uses Entity Framework. We create classes that map to database tables. We observe how our target database is created when the project is run. Finally, we save and retrieve our first data from the created database.

Chapter 3, Defining the Database Structure, dives deep into details of mappings between classes and tables. We create maps between properties to columns as well as rules that govern such mappings. We define relationships between classes that translate into relationships between tables. We exercise multiple approaches that can be used to define the mappings.

Chapter 4, Querying, Inserting, Updating, and Deleting Data, discusses how to use the LINQ API, that allows developers to retrieve the data from the database. We sort, filter, and perform element operations and use quantifiers. We query related entities. You learn the advantages and pitfalls of eager and lazy loading. We insert, delete, and update the data.

Chapter 5, Advanced Modeling and Querying Techniques, dives deeper into modeling and querying techniques. We use complex types to have more consistency in the database structures. We create an explicit table and column names. We define structures that use table and entity splitting. We use projections in queries to make them more efficient and summarize our data. We page the data for retrieval, breaking it up for presentation to the users. We use joins to create queries that use related entities.

Chapter 6, Working with Views, Stored Procedures, the Asynchronous API, and Concurrency, shows how to access with database views from Entity Framework. We query data via stored procedures using the Entity Framework API. We perform create, update, and delete operations with stored procedures. We exercise Entity Frameworks and the asynchronous API and learn the advantages and pitfalls of asynchronicity. We implement concurrency handling, learning to handle the situation when multiple users attempt to update the dame data.

Chapter 7, Database Migrations and Additional Features, shows how to enable migrations on our Entity Framework project, creating and updating the database schema without data loss. We use implicit migrations first, then create explicit migrations, customizing our migration code. We use common aspects of the migrations API, adding columns and specifying default values. We apply migrations using multiple approaches. We create migrations from an existing database. We dive briefly into useful Entity Framework features, not covered previously.

Appendix, Answers to Self-test Questions, contains answers to questions you will find throughout the book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.93.175