In this slides you will learn about Entity Framework and Object Relational Mappers,how to install visual studio 2017 and .NET Core,then created the solution and projects. After getting the tools installed learn the theory behind EF core and CRUD operations. In Final repository functions.
2. WHAT WE GET FROM THE CHAPTER
Some New Definitions.
Installing Visual Studio 2017
Open a new Projects.
Updating Using Entity State
Deleting Records using Entity State
Adding the Core Repository Interface and Base Class
1/19/2018JOYANTA KUMAR SARKER,16103352,CEAT,IUBAT
2
3. WHAT IS ENTITY FRAMEWORK CORE ?
Entity Framework (EF) Core is a lightweight, extensible, and
cross-platform version of the popular Entity Framework
data access technology.
EF Core is an object-relational mapper that enables .NET
developers to work with a database using .NET objects. It
eliminates the need for most of the data-access code that
developers usually need to write.
1/19/2018JOYANTA KUMAR SARKER,16103352,CEAT,IUBAT
3
4. DATA ANNOTATIONS IN
ENTITYBASE
Data Annotation in .Net framework means add extra meaning to
the data by adding attribute tags. The advantage of using Data
Annotation feature is that by applying Data Attributes we can
manage the data definition in a single place and do not need re-
write the same rules in multiple places.
The Data Annotation feature got introduced in .Net 3.5 and
the System.ComponentModel.DataAnnotations namespace
contains the classes that are used as data attributes.
1/19/2018JOYANTA KUMAR SARKER,16103352,CEAT,IUBAT
4
5. MIGRATIONS
When application models are added,deleted or changed,the physical data store needs
to be updated to match the shape of the application data model.
I. Create , delete, or update the model classes or the context class.
II. Create a new migration.
III. Apply that migration to the database. Or create the script file for the migration for
execution elsewhere.(such as SQL Server Management Studio)
1/19/2018JOYANTA KUMAR SARKER,16103352,CEAT,IUBAT
5
6. OBJECT-RELATIONAL MAPPING
Object-relational mapping is a programming technique
for converting data between incompatible type
systems using object-oriented programming languages.
1/19/2018JOYANTA KUMAR SARKER,16103352,CEAT,IUBAT
6
9. 1/19/2018JOYANTA KUMAR SARKER,16103352,CEAT,IUBAT
9
Updating
Using
Entity State
Make sure the
entity is not already
being tracked in the
context
Create a new
instance of the
Category class
Set all of the fields
to the correct values
Set the EntityState
to
EntityState.Modified
Call SaveChanges()
on the StoreContext
11. ADDING THE CORE REPOSITORY INTERFACE
AND BASE CLASS
A common data access design pattern is the
repository pattern . This helps to eliminate
duplication of code.
1/19/2018JOYANTA KUMAR SARKER,16103352,CEAT,IUBAT
11