Entity Framework By: Casey Griffin.

Slides:



Advertisements
Similar presentations
Introduction to NHibernate By Andrew Smith. The Basics Object Relation Mapper Maps POCOs to database tables Based on Java Hibernate. V stable Generates.
Advertisements

Michael Pizzo Software Architect Data Programmability Microsoft Corporation.
Object Relational Mapping – ORM Entity Framework
Shyam Pather Development Manager Microsoft Session Code: DTL402.
.NET Database Technologies: Open-Source Frameworks.
ORM Technologies and Entity Framework (EF)
Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify.
Introduction to ADO Entity Framework ir Denis VOITURON Source:
Hibernatification! Roadmap for Migrating from Plain Old SQL on JDBC to JPA on Hibernate Duke Banerjee Senior Developer, DrillingInfo.com.
Rice KRAD Data Layer JPA Design Eric Westfall July 2013.
1 Entity Framework Introduction. Outline Goals of Entity Framework 2.
Introduction to MVC Adding Model Classes NTPCUG Tom Perkins, Ph.D.
Entity Framework Code First End to End
.NET Database Technologies: Entity Framework additional notes – part 2.
LINQ Boot Camp ADO.Net Entity Framework Presenter : Date : Mahesh Moily Nov 26, 2009.
Entity Framework, a quickstart Florin−Tudor Cristea, Microsoft Student Partner.
Eric Nelson (or )
NHibernate in Action Web Seminar at UMLChina By Pierre Henri Kuaté 2008/08/27
Visual Studio 2010 and.NET Framework 4 Training Workshop.
Database Technical Session By: Prof. Adarsh Patel.
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Entity Framework Overview. Entity Framework A set of technologies in ADO.NET that support the development of data-oriented software applications A component.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
.NET Database Technologies: Data Models and Patterns.
Ventsislav Popov Crossroad Ltd.. 1. ASP.NET Data Source Controls  SqlDataSource  EntityDataSource  ObjectDataSource 2. Entity Data Model and ADO.NET.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 14 Using Relational Databases to Provide Object Persistence (Overview) Modern Database.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Entity Framework Code First – Beyond the Basics Sergey Barskiy, Magenic Microsoft MVP – Data Platform Principal Consultant.
Oct * Brad Tutterow. VS 2008.NET 3.5LINQ Entity Framework  The ADO.NET Entity Framework is part of Microsoft’s next generation of.NET technologies.
EntityFrame work and LINQ CH 14. linq LINQ enables you to query data from a wide variety of data sources, directly from your programming code. LINQ is.
Entity Framework: Code First SoftUni Team Technical Trainers Software University
Ventsislav Popov Crossroad Ltd.. 1. ASP.NET Data Source Controls  SqlDataSource  EntityDataSource  ObjectDataSource 2. Entity Data Model and ADO.NET.
Entity Framework Code First – Beyond the Basics Sergey Barskiy, Magenic Microsoft MVP – Data Platform Magenic, Principal Consultant Level: Introductory.
Entity Framework 7 Who Are You & What Have You Done to my ORM?
Simplifying the Code First Approach in the Entity Framework Dhananjay Kumar Infragistics Consultant Microsoft MVP
Entity Framework 7: What’s New? Ricardo Peres Technical Evangelist at Simplifydigital. Microsoft
Stuart Leitch “Code First” & DbContext.
ORM Basics Repository Pattern, Models, Entity Manager Ivan Yonkov Technical Trainer Software University
2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK
Top 10 Entity Framework Features Every Developer Should Know
Introduction to Entity framework
Introduction to .NET Florin Olariu
Introduction to Entity Framework
Entity Framework: Code First
Entity Framework DB From Code, OOP Introduction
A very brief introduction
 .NET CORE
Did your feature got in, out or planned?
Entity Framework Core for Enterprise Applications
Learn. Imagine. Build. .NET Conf
ADO.NET Entity Framework Marcus Tillett
ADO.NET Entity Framework
ADO.NEXT Advances in Data Access for 2008
Microsoft Build /15/2018 6:28 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
An Introduction to Entity Framework
File Systems and Databases
.NET Database Technologies:
Entity Framework Core.
Accessing Data in a .NET Web Application
Introduction to .NetTiers
Entity Framework Core (EF Core)
Jeff Webb Maria Baron Chris Hundersmarck
Chapter 10 ADO.
IT College 2016, Andres käver
Entity Framework Core for Enterprise Applications
TechEd /3/ :48 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Developing and testing enterprise Java applications
Entity Framework & LINQ (Language Integrated Query)
Visual Studio 2010 and .NET Framework 4 Training Workshop
Presentation transcript:

Entity Framework By: Casey Griffin

What is Entity Framework? Object-Relational Mapper Object Programming / Database Programming Create Model (Code/EF Designer) Part of the ADO.NET Stack – Between the applications and databases Higher Level of Data Abstraction Create/Maintain Data-Oriented Applications with Less Code Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write. Entity Framework allows you to create a model by writing code or using boxes and lines in the EF Designer. The Entity Framework is the preferred method of data access for .NET applications, supporting strongly-typed access through LINQ. The Entity Framework can also be used from an ASP.NET application through the Entity Data Source. With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented applications with less code than in traditional applications

Conceptual Model Entity Data Model – EDM /Domain Model Represents Domain Objects/ Relationships between Entities Reflects Application Logic Higher Level of Abstraction The Entity Framework allows developers to program against a conceptual model that reflects application logic rather than a relational model that reflects the database structure. EDM represents your domain objects and relationships between entities. Not tightly bound to data source or the application. Entities do not have to have a single table or data source.

Development Workflows Four workflows – Are you targeting a new database or an existing database? Would you like to work with a model or with code?

Code First Approach Since Entity Framework 4.1 Workflow Domain (POCO) Classes DbContext API Code First Migrations Code First lets you use your own classes as your data model and supports automatically creating a database or using an existing database.

POCO Classes Plain Old CLR Object Classes Persistent Ignorance Types of Properties: Scalar Properties Navigational Properties Virtual Keyword (Lazy Loading) Domain name classes which have no dependence on Entity Framework – Persistent Ignorance. Scalar properties are like ID and Name and describe properties of the object. Navigational Properties describe the relationships between classes. Adding in the virtual Keyword allows for EF feature of Lazy Loading which is basically load these properties only when they are needed.

DbContext Lightweight version of the ObjectContext Represent Database Session Querying and Saving Data DbSet (ObjectSet)– Query and Save Instances of Database Types Lightweight version of object context used to managing entities. The DbContext will handle the classes and pull them into Entity Framework. DbContext focuses on the most commonly used things people do with Entity Framework. The DbContext represents a session with the database and allows for selecting, inserting, updating, and deleting functions. CRUD operations. Define a DbSet for every type that is in the model and allows us to query and save instances of those database types The DbContext is a main object in Code First that exposes the interaction between the Entity Framework and the database. Its responsibilities include database connectivity, change tracking, data persistence, entities caching and more. It's also a container of all the DbSets that you'll create in order to work against the database. The DbSet is a collection representation of a set of entities. You can think about it as an in-memory representation of database records, but it's much more than that. It exposes a set of collection methods such as Add and Remove in order to manipulate the set's data. It also enables you to use LINQ to Entities to query its data.

Code First Conventions Conventions determine the database schema based on the domain model Configuring/Overriding Conventions Data Annotations Fluent API EF Code First uses a set of conventions to work out what the database schema should be created based on how we defined out classes in the domain model. Determine the shape of classes and what the database will look like. There are times when your classes aren't going to be following what Code First is expecting or you want to change what the database looks like.

Data Annotations Data Annotations helps configure Code First Conventions within the POCO classes. Adding annotations such as key help to Code First Conventions to identify what the key of the class should be.

Fluent API To use Fluent API, you override the OnModelCreating method within the DbContext. You can then configure entities and mappings as you like.

Code First Migrations Enable Migrations Generating Seed Data Adding Migrations Updating the Database Making changes to the domain model thus making changes to the database schema. Enable Migrations for the DbContext. Configuration file with seed data. Migrations keeps track of which migrations have been applied to the DbContext

The Griffin Drywall Project The Website Demo

Analysis Comparison with Traditional Data Access Entity Framework Features Benefits and Disadvantages

Features Conceptual Layer –Multiple Backends Lazy Loading LINQ Querying Many to Many Relationships – Bridging Tables Conceptual Layer goes with persistent ignorance and can be placed on top of different data source providers without any or little coding changes. Lazy Loading enables us to only use resources when they are needed. LINQ Querying – Parameterized SQL statements prevents SQL injection. LINQ queries are against the conceptual model and therefore queries will not have to change with changes to the underlying database or physical model. LINQ uses caching so repetitive query will perform better

Benefits and Disadvantages Bulk of 80-90% of CRUD Functions 10-20% SQL or Stored Procedures Rapid Development Speeds Not As Flexible as SQL/SP Maintainable Code Bad Generated SQL Isolated from Database EF used for most common CRUD Functions but bulk updates are better preformed with raw SQL or Stored Procedures EF will update conceptual model and physical/storage/database model as you would therefore keeping things in sync. Code is built around the conceptual model, the business logic and therefore queries are readable without knowing the database storage schema. SQL/SP can do more specific querying that EF cannot do eloquently

Conclusion Entity Framework is easy to use and endows developers with higher level of abstraction which allows them to deal with the business logic rather than the database logic. Future Projects Model First Approach EF vs Current ORMs

Questions Open the presentation up for questions.