What is Entity Framework?
It is an Object Relational Mapper (ORM) that enables programmers to communicate with a relational database.
What is ORM?
Object Relational Mapper processes a relational database and mapping in such a way that programmers can use it in their code easily.
Why Entity Framework?
Using this we can do all the DB select, insert, update, and delete operations without writing ADO .Net code that we write for every single query of a database.
- To do faster development use Entity Framework
- Connect with any database like SQL or Oracle
- Auto-generated Model
- Works well with Stored Procedures
First, create a table in your database I have attached my DB structure here.

Now in Visual Studio add a new item ADO Entity Model.


Select your database and save the entity to do CRUD operations.

Select your tables.

After clicking on Finish an edmx is created for your project.
Now
Create Entity Object to do CRUD operations
FirstDayEntities ObjEntity = new FirstDayEntities();
#region Read All Merchants
var ObjMerchantsList = ObjEntity.Merchants;
#endregion
#region Insert
Merchant ObjMerchant = new Merchant() { Name = "Mangesh Gaherwar", Address = "Solapur" };
ObjEntity.AddToMerchants(ObjMerchant); // ObjEntity.Merchants.AddObject(ObjMerchant); //both r same
int InsertResult = ObjEntity.SaveChanges();
#endregion
#region Update
Merchant ObjUpdateMerchant = ObjEntity.Merchants.Where<Merchant>(a => a.Name == "Mangesh Gaherwar").FirstOrDefault();
ObjUpdateMerchant.Address = "Kamote";
int UpdateResult = ObjEntity.SaveChanges();
#endregion
#region Delete
Merchant ObjDeleteMerchant = ObjEntity.Merchants.Where<Merchant>(a => a.Name == "Mangesh Gaherwar").FirstOrDefault();
ObjEntity.Merchants.DeleteObject(ObjDeleteMerchant);
int DeleteResult = ObjEntity.SaveChanges();
#endregion
That's it.
If your database table structure is the same then only change the connection string in the web. config
We will see some more fundamentals in Practical of Entity Framework Day 2.
Please find the attached source code Zip.
Thank you for reading.
Go to part 2

Mahesh AllePosted Aug 26, 2014, 2:12 AM
Simple to understand. Thanks for posting this one.
Sandeep SharmaPosted Jul 24, 2014, 3:34 AM
Is it also possible with ms-access or mysqli database ?? if so, how and if not then why so ?? thanks in advnce fr ur reply...
Sai SherlekarPosted Jun 22, 2014, 10:03 AM
ok, thnk u so much sukesh for giving me such great tips.. i already submitted Day2 but it is under review. so i will apply these tips to next all my articles.. thnx again
Sukesh MarlaPosted Jun 22, 2014, 6:12 AM
Waiting for day 2..Some inputs 1) First talk about the agenda. 2)Put some images expressing definitions. 3)Dont put databse name as your name ;) Keep it meaningfull like CustomerManagementSystem......Hope you will complete your series soon :)