What is the difference between Entity Framework and LINQ to SQL? Entity Framework: "Supports databases like SQL, MySQL, DB2 etc. Allows one-to-one, one-to-many & many-to-many mappings between the Entity classes and the relational tables. Relationships are maintained in 3 different files - .csdl, .msl and .ssdl. Supports Complex Types. Supports Rapid application development with SQL Server, DB2, MySQL etc. LINQ to SQL: Supports only for SQL database. Allows only one-to-one mapping between the entity classes and the relational tables. .dbml file is generated for maintaining the relationships. No Support for Complex Types. Supports Rapid application development with SQL Server.
What is the difference between ExecuteScalar and ExecuteNonQuery? ExecuteScalar returns output value where as ExecuteNonQuery does not return any value but the number of rows affected by the query. ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements.
What is the difference between lazy loading and eager loading? Lazy and eager loading are two different ways that Entity will load related data (like the Orders attached to our Customers).
Lazy loading means that when an entity is first read, its related entities are not loaded. Entity Framework waits until you try to access those entities before querying the database again. This can lead to multiple database queries. For instance, the following code will result in two different database queries: