Entity Framework vs LINQ to SQL

LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It’s a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5. LINQ to Entities (ADO.Net Entity … Read more

Unable to determine the principal end of an association between the types

That exception is launched because you are trying to configure an one-to-one relationship but you are not specifying which end is the principal in the relationship. Principal end is the one which will be inserted first and which can exist without the dependent one. Dependent end is the one which must be inserted after the principal because it has foreign key to the … Read more

entity object cannot be referenced by multiple instances of IEntityChangeTracker. while adding related objects to entity in Entity Framework 4.1

Because these two lines … … don’t take a parameter in the constructor, I guess that you create a context within the classes. When you load the city1… …you attach the city1 to the context in CityService. Later you add a city1 as a reference to the new Employee e1 and add e1 including this reference to city1 to the context in EmployeeService. As a result you have city1 attached to … Read more

EF CodeFirst: Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong

This is because of name Conflict of Class (Model) names with other reserved or generated ones, when auto creates the tables and … . Considering that EF Code First creates the intervene tables to relate 2 or more tables using name of tables for derived intervene table, so when you use a class name that employs a … Read more