EntityState.Detached, do I need to reload?

All, Using .Net 4 and EF 4.4 Database First. Let's say I have a DbContext. I load data from this DbContext, do stuff, and then detach everything from the DbContext and dispose of the DbContext. Then, I create a new DbContext (same model) and load oth

Using a transaction to undo changes with the Entity Framework

I have this specific DAO that inherits methods from a generic DAO I would like to add a transaction to this code in order to roll back all changes that where made if an exception is found TDAO tDAO = new TDAO(); TDAO2 tDAO2 = new TDAO2(); //Get the D

Where is ODATA EF for VWD 2010 Express?

I'm currently using VWD 2010 Express and am interested in exploring WCF REST in more detail, but I can't find "ADO.NET Entity Data Model" template or any information on how to install it. Is it correct that this is also referred to as ODATA Enti

How to update the navigation properties / linked tables in EF?

I have an object Customer with a navigation property Days (days is a separate table which have - day_id, customer_id - FK). mycontext.Customers.ApplyCurrentValues(cust); mycontext.SaveChanges(); This only updated the scalar properties of Customer, no

Entity Framework 4 does not support SQLite

I am using Entity Framework 4 code first method to automatically create SQLite database, I get an error telling me ProviderIncompatibleException: [System.Data.ProviderIncompatibleException] = {"CreateDatabase is not supported by the provider."}

Exception while trying to insert entities using EF4.3.1

I've seen some posts here that look like mine, however I couldn't find the answer to my specific problem. The thing is that I'm trying to insert an entity into the DB using a nav. prop. however I'm constantly getting: The ObjectContext instance has b

How to dynamically change themes and _Layout in ASP.Net MVC4

I want to be able to change the _Layout.cshtml view based on a setting in my database. I understand that it is probably done in the _ViewStart.cshml view. I am using EF 4.2 and want to adapt a solution that will not break any design pattern. Not sure

Get the list of properties of an entity

I'm using entity framework. I would like to get the property list of an entity when the EntityState of the object is "Added", and loop throught them. here is a sample code of what I'm doing. var newEntities = ObjectStateManager.GetObjectStateEnt

How to load non-entity queries?

I have this in my WCF domain service: public List<string> GetTop5ActiveUsersByManagementMessages() { return this.ObjectContext.Logs .Where(w => w.Message == "Created User" || w.Message == "Removed User" || w.Message == "U

Navigation properties on join tables in Entity Framework

So I have a table in my SQL database: CompanyRelationships -------------------- ID CompanyID RelatedCompanyID PermissionGroupID Which defines when a company allows access to it's records to another company. The "CompanyID" is the company that is

Code EF4 First creation of singular table names

I'm using standards for singular table names. EF4 Code First has by default to pluralize table names. I have put the code to override this convention, but seems is not working. using section: using System; using System.Collections.Generic; using Syst

In EF 4.1 DbContext how to trace SQL generated

I wonder how to trace generated SQL like DataContext in LinqToSql. I also read articles about the solution of EFProviderWrapper on Jaroslaw Kowalski's blog, but it is based on ObjectContext, does not work for DbContext. Anyone know how to do this in

How to clean / reset ObjectContext in EF 4

I have an hierarchical structure with millions of records. I'm doing a recursive scan on the DB in order to update some of the connections and some of the data. the problem is that I get an outofmemory exception since the entire DB is eventually load

Debug Visual Studio 2010 Templates

I'm using the visual studio POCO Template for the Entity Framework, so far it has worked great, but since my database/tables are not Upper Cammel Case, but UPPER case, every time that i need to regenerate the entities, i also need to (manually) chang

Join tables using more than one column in Linq To Entities

Every single example of joins in Linq to Entities involves only one column in the on clause. What is the syntax if I need 2 or more columns to make the join work? I would need an example for Linq to Entities Query Expressions and Method Based also, i

EF query with the conditions of several tables

I have a table named "Employees". The employeeId from this table MAY be in another table (a many-to-many join tbale) named "Tasks". The other field in the "Tasks" table is a taskId linked to the "TaskDetails" table.

Validation of entity objects and validation of business rules

I am developing application having business objects created from EF 4.0. The application is layered with Data Layer having repository of classes. Above that is a business layer where business processes are mapped as per the requirements. Business lay

How to get the first EntityKey name for an entity in EF4

How can I get the 1st EntityKey name for an Entity for Entity Framework 4 because I'm building a repository system and I wanted to get an item by Id (which is the primary key oin EF is the 1st entitykey for the entity) I'm using this code public virt

Is it possible to install EF4 on VS2008 SP1?

After googling, I have only found only this sad forum question. Is it true I can't install EF4 on VS 2008 SP1? And if I can, how to do it - just install .NET 4 beta 2?EF4 is part of the .NET 4 / Visual Studio 2010 wave of prodcuts. I don't know of an