The article provides a quick guide to understanding Entity Framework.

Why Entity Framework?

Entity Framework is an ORM layer which implements the Unit of Work pattern. The library keeps a track of all changes made to database entities. It saves all changes in a single transaction.

DbContext class keeps track of the entities. The SaveChanges method saves multiple updates in a single transaction.…

Read More

ASP.NET Identity Framework 2.0 is integrated with EntityFramework. The entity classes available are Users, Roles, Claims and Logins. The Identity database can be any store – SQL Server, MySQL or Oracle. This article provides guidance on how to integrate ASP.NET Identity 2.0 with a MySQL database.

SQL scripts for MySQL

MySQL has naming conventions which are very different from SQL Server.…

Read More

Entity Framework is an ORM framework for .NET applications. We specify the mapping between .NET classes and corresponding database tables. Tables are related to one another. The common relations are One-to-One, One-to-Many or Many-to-Many.

  • One-to-One: Record in TableA maps to a record in TableB.
  • One-to-Many: Record in TableA maps to multiple records in TableB.
  • Many-to-Many: Record in TableA maps to multiple records in TableB and one record in TableB maps to multiple records in TableA.
Read More

SQLite is an open-source SQL database engine. It is widely used in iOS apps. The database is available in the form of a file.

Create Database

To create a database with name accounting:

sqlite3 accounting.sqlite

.tables is a command which lists all tables. Add a new table, Company. And insert a few rows.

CREATE TABLE company 
(id int, seats int);
INSERT INTO company (id, seats)
VALUES (1, 20);
INSERT INTO company (id, seats)
VALUES (2, 30);
INSERT INTO company (id, seats)
VALUES (3, 50);

ALTER TABLE has restricted syntax.…

Read More

Entity Framework is an ORM layer for .NET applications. Sometimes, we import data from a flat file. Technically, this boils down to: Delete all records from the table. And insert new records into the table.

Import data

Below is the first cut of code that I wrote. A logical use of Entity framework. But unexpectedly, yields very poor performance.

// delete data
foreach(Employee emp in context.Employees)
Read More