http://www.entityframeworktutorial.net/code-first/simple-code-first-example.aspx
Saturday, 25 June 2016
Entity Framework Questions
1. What is Entity Framework?
2. What are the benefits of using EF?
3. What are the different ways of creating these domain / entity objects?
4. What is pluralize and singularize in EF dialog box?
5. What is importance of EDMX file in EF?
6. Can you explain CSDL, SSDL and MSL section in an EDMX file?
7. What are T4 templates?
8. What is the importance of T4 in EF?
9. Hoe can we read records using EF classes?
10. How can we add, update and delete using EF?
2. What are the benefits of using EF?
3. What are the different ways of creating these domain / entity objects?
4. What is pluralize and singularize in EF dialog box?
5. What is importance of EDMX file in EF?
6. Can you explain CSDL, SSDL and MSL section in an EDMX file?
7. What are T4 templates?
8. What is the importance of T4 in EF?
9. Hoe can we read records using EF classes?
10. How can we add, update and delete using EF?
Friday, 24 June 2016
ADO.NET Entity Framework Version History
1) Explain what ADO.NET entity framework is?
ADO.NET entity framework is an ORM (Object Relational Mapping) framework developed by Microsoft. It is an extension of ADO.NET that provides an automated mechanism to access and store data in the database. With the help of ADO.NET, database can be accessed without much required programming or code.
2) Mention what is the key advantage of using Entity Framework or EF?
The main advantage of using Entity Framework or EF is that it generates code automatically for the Model (Middle Layer), Mapping code and Data Access Layer. It reduces a lot of time during the development process.
3) Explain what does .edmx file contains?
.edmx file is an XML file, which declares a conceptual model, a storage model and the mapping between these models. This file also consists the information that is used by ADO.NET entity data model designer to render a model graphically. It consists of all the mapping details of how object maps with SQL tables. It is divided into three categories SSDL, CSDL, and MSL.
4) Mention what is CSDL, SSDL and MSL sections in an EDMX file?
• CSDL: It stands for Conceptual Schema Definition Language, it is the conceptual abstraction which is exposed to the application
• SSDL: It stands for Storage Schema Definition Language, it defines the mapping with our RDBMS data structure
• MSL: It stands for Mapping Schema Language, it connects the SSDL and CSDL
5) Mention what is the difference between LINQ to SQL and Entity Framework?
|
It works only with
SQL Server Database
|
It works with
various database like DB2, MYSQL, SQL Server etc.
|
|
To maintain the
relation it generates a .dbml
|
It creates an .edmx
files initially and relation is maintained using 3 different files .msl,
.csdl and .ssdl
|
| It cannot generate
database from model |
It can generate
database from model
|
|
It permits one to
one mapping between the entity classes and relational views/tables
|
Between the entity
classes and relational tables, it permits one-to-one, one-to-many and
many-to-many
|
|
It enables you to
query data using DataContext
|
It enables you to
query data using EntitySQL, DBContext, and ObjectContext
|
|
It provides tightly coupled approach
|
It provides loosely coupled approach
|
6) How can you enhance the performance of Entity Framework?
To enhance the performance of Entity Framework, you have to follow the following steps
• Try to avoid to put all the DB objects into one single entity model
• Disable change tracking for entity if not needed
• Reduce response time for the first request by using pre-generating Views
• If not required try to avoid fetching all the fields
• For data manipulation select appropriate collection
• Wherever needed use compiled query
• Avoid using Views and Contains
• While binding data to grid or paging, retrieve only required no of records
• Debug and Optimize LINQ query
7) Explain why T4 entity is important in Entity Framework?
T4 entity is important in Entity framework as it is the heart of entity framework code generation. It reads the EDMX XML file and generate C# behind code.
8) Explain how you can load related entities in EF (Entity Framework)?
You can load related entities or data in EF in three ways
• Eager Loading
• Lazy Loading
• Explicit Loading
9) Explain Lazy loading, Eager Loading, and Explicit Loading?
• Lazy Loading: It is a process to delay the loading of related objects until it is required.
• Eager Loading: It occurs when you query for an object and all of the related objects are also returned. In eager loading, related objects are loaded automatically with its parent object
• Explicit Loading: Explicitly loading takes place when you have disabled Lazy loading, and you still want to lazy loading. For this, we have to call the load method on the related entities.
10. How many Type of approaches available in Entity Framework?
There are 3 approaches in Entity Framework
- Database First
- Model First
- Code First
Database First
Database first is the approach in which our database has already generated. And using this database we create our Model and code in entity framework.
Model First
In Model first we create designer (model) first. If database not exist then we can create database using this designer
Code First
In code first we create code file first and then if database not exist then database will be created automatically at runtime using this code.
11. What is ObjectContext class in Entity Framework?
ObjectContext is the class which helps us to perform Insert, Update, Delete and create in Entity Framework.
This class is available in System.Data.Entity namespace.
12. Is it necessary to have EDMX file in code first approach
No, it is not necessary.
13. How can we specify key column in Code first approach.
By assigning a [key] attribute on property.
For Example
[Key]
public int emp_id { get; set; }
14. Which namespace we use in Code first approach to use [key] attribute
System.ComponentModel.DataAnnotation
15. Which namespace we use in Code first approach to use [Foreign key] attribute
System.ComponentModel.DataAnnotation.Schema
ADO.NET Entity Framework Version History
ADO.NET Entity Framework Version
6.0
|
.NET Framework 4.5.1 and Visual Studio 2013
1.
Async Query and Save
2.
Code-Based Configuration
3.
Dependency Resolution
4.
Interception/SQL logging
5.
Improved Connection Management
6.
Improved Transaction Support
|
5.0
|
.NET Framework 4.5 and Visual Studio 2012
1.
Enum Support in Code First and EF
Designer
2.
Spatial Data Types in Code First and EF
Designer
3.
Table-Valued Functions
4.
Multiple Diagrams per Model
|
4.3
|
.NET Framework 4.0 and Visual Studio 2010
1.
Code First Migrations
2.
Automatic Migrations
|
4.2
|
.NET Framework 4.0 and Visual Studio 2010
1.
The EF 4.2 release included the bug
fixes to EF 4.1
|
4.1
|
.NET Framework 4.0 and Visual Studio 2010
1Code First development
2.
Introduced DbContext API
3.
Data Annotations and Fluent API
Validation
|
4.0
3.5 |
.NET Framework 4.0 and Visual Studio 2010
1.
Model-first development
2.
POCO support
3.
Lazy Loading
4.
T4 Code Generation
.NET
Framework 3.5 SP1 and Visual Studio 2008 SP1
1. This releaseprovided basic O/RM support using the Database
first development
|
Subscribe to:
Posts (Atom)