Questions tagged [entity-framework-4]

A tag for ADO.NET Entity Framework 4.x, itself an object-relational mapping for the .NET framework.

The ADO.NET Entity Framework version 4.0, a feature of .NET 4.0 and higher.

The Entity Framework released for .NET 3.5 comes with Database First support. (tag: entity-framework)

The Entity Framework v4.0 released with .NET 4.0 added Model First support. (tag: entity-framework-4)

The Entity Framework v4.1 added Code First and DbContext support. (tag: entity-framework-4.1)

See for more information.

7399 questions
874
votes
29 answers

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details

I am having this error when seeding my database with code first approach. Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. To be honest I don't know how to check the content of the validation…
Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
787
votes
21 answers

There is already an open DataReader associated with this Command which must be closed first

I have this query and I get the error in this function: var accounts = from account in context.Accounts from guranteer in account.Gurantors select new AccountsReport { CreditRegistryId…
DotnetSparrow
  • 27,428
  • 62
  • 183
  • 316
553
votes
16 answers

EF Migrations: Rollback last applied migration?

This looks like a really common task, but I can't find an easy way to do it. I want to undo the last applied migration. I would have expected a simple command, like PM> Update-Database -TargetMigration:"-1" Instead, all I can come up with is: PM>…
410
votes
19 answers

Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths - why?

I've been wrestling with this for a while and can't quite figure out what's happening. I have a Card entity which contains Sides (usually 2) - and both Cards and Sides have a Stage. I'm using EF Codefirst migrations and the migrations are failing…
SB2055
  • 12,272
  • 32
  • 97
  • 202
389
votes
11 answers

Entity Framework Timeouts

I am getting timeouts using the Entity Framework (EF) when using a function import that takes over 30 seconds to complete. I tried the following and have not been able to resolve this issue: I added Default Command Timeout=300000 to the connection…
Halcyon
  • 14,631
  • 17
  • 68
  • 99
265
votes
27 answers

The model backing the context has changed since the database was created

The error message : "The model backing the 'AddressBook' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the…
Ashish Gupta
  • 14,869
  • 20
  • 75
  • 134
250
votes
2 answers

What effect(s) can the virtual keyword have in Entity Framework 4.1 POCO Code First?

Does the virtual keyword has an effect when used on the properties in EF Code First?. Can someone describe all of its ramifications in different situations? For instance, I know it can control lazy loading -- if you use the virtual keyword on an…
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
238
votes
17 answers

How to update only one field using Entity Framework?

Here's the table Users UserId UserName Password EmailAddress and the code.. public void ChangePassword(int userId, string password){ //code to update the password.. }
h3n
  • 5,142
  • 9
  • 46
  • 76
223
votes
8 answers

The object 'DF__*' is dependent on column '*' - Changing int to double

Basically I got a table in my EF database with the following properties: public int Id { get; set; } public string Title { get; set; } public string Description { get; set; } public string Image { get; set; } public string WatchUrl { get; set;…
Jordan Axe
  • 3,823
  • 6
  • 20
  • 27
218
votes
5 answers

What's the difference(s) between .ToList(), .AsEnumerable(), AsQueryable()?

I know some differences of LINQ to Entities and LINQ to Objects which the first implements IQueryable and the second implements IEnumerable and my question scope is within EF 5. My question is what's the technical difference(s) of those 3 methods?…
187
votes
20 answers

Entity Framework: table without primary key

I have an existing DB with which I would like to build a new app using EF4.0 Some tables do not have primary keys defined so that when I create a new Entity Data Model, I get the following message: The table/view TABLE_NAME does not have a primary…
Cris
  • 12,124
  • 27
  • 92
  • 159
183
votes
12 answers

Entity Framework 4 / POCO - Where to start?

I've been programming for a while and have used LINQ-To-SQL and LINQ-To-Entities before (although when using entities it has been on a Entity/Table 1-1 relationship - ie not much different than L2SQL) I've been doing a lot of reading about Inversion…
Basic
  • 26,321
  • 24
  • 115
  • 201
176
votes
2 answers

Entity Framework Join 3 Tables

I'm trying to join three tables but I can't understand the method... I completed join 2 tables var entryPoint = dbContext.tbl_EntryPoint .Join(dbContext.tbl_Entry, c => c.EID, cm => cm.EID, …
176
votes
4 answers

How to include a child object's child object in Entity Framework 5

I am using Entity Framework 5 code first and ASP.NET MVC 3. I am struggling to get a child object's child object to populate. Below are my classes.. Application class; public class Application { // Partial list of properties public…
171
votes
12 answers

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid

I have a one entity framework object and when I add it to my project, the connectionstring is added to app.config in the connectionstring section, but when I want to create new entitycontext and use this connectionstring, this error appears
user421413
  • 1,731
  • 2
  • 11
  • 3
1
2 3
99 100