tagged [entity-framework-4]

Entity Framework multiple counts with a single query

Entity Framework multiple counts with a single query Sorry if this has been asked, but how can I improve the following with a single call to the database?

Entity Framework - default values doesn't set in sql server table

Entity Framework - default values doesn't set in sql server table SQL server 2005 database table has a column 'createdon' for which default value set to getdate(). I am trying to add a record using en...

Entity Framework Code First CTP4 Default Column Values?

Entity Framework Code First CTP4 Default Column Values? I have been looking into Code First with Entity Framework CTP4 and you can use the ModelBuilder to build up your table columns. Is there a way t...

27 Oct at 19:4

Can you create sql views / stored procedure using Entity Framework 4.1 Code first approach

Can you create sql views / stored procedure using Entity Framework 4.1 Code first approach Entity Framework 4.1 Code First works great creating tables and relationships. Is it possible to create sql v...

Getting the connectionstring in .net 4

Getting the connectionstring in .net 4 I want to get a connection string from the `app.config` file. `connectionString = System.Configuration.ConfigurationSettings.AppSettings["DBEntities"];` But it d...

26 Apr at 17:54

What is the difference between IDbSet.Add and DbEntityEntry.State = EntityState.Added?

What is the difference between IDbSet.Add and DbEntityEntry.State = EntityState.Added? In EF 4.1+, is there a difference between these 2 lines of code? Or do they do the same thing? I'm wondering if o...

31 Jan at 16:15

Entity Framework - printing EntityValidationErrors to log

Entity Framework - printing EntityValidationErrors to log I get the follo0wing error when I print my log The EntityValidationErrors object holds the full detailed error in different nodes. What

Using a enum with flag in an Entity Framework query

Using a enum with flag in an Entity Framework query i have a enum type like below ``` [Flags] public enum WeekDays { Monday = 1, Tuesday = 2, Wednesday = 4, Thursday = 8, Frida...

circular dependency in entity framework

circular dependency in entity framework Is it possible to save model which has got circular dependency ? I denormalized my Database: Is it possible to save sth like this using entityFramework? what sh...

18 Feb at 12:11

Unique key with EF code first

Unique key with EF code first I have a following model in my project and I'm trying to make `Title` as unique key, I googled for the solution, but couldn't find any. Can any suggest me how to do it, p...

Entity Framework Code First Date field creation

Entity Framework Code First Date field creation I am using Entity Framework Code First method to create my database table. The following code creates a `DATETIME` column in the database, but I want to...

Why is entity still validated when it is gone?

Why is entity still validated when it is gone? 1. Add a new entity to a TrackableCollection (context.Entities.Add(entity)) (EntityState = New) 2. Without saving, delete the added entity from Trackable...

Set Command Timeout in entity framework 4.3

Set Command Timeout in entity framework 4.3 I cannot find the a way to set the command timeout of a linq query using entity framework 4.3 and its' DbContext. How do I increase Commandtimeout in entity...

Is DbContext the same as DataContext?

Is DbContext the same as DataContext? I'm following a tutorial by [Scott Gu](http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx) that refers to a cla...

12 Aug at 19:47

Custom SQL functions and Code First (EF 4.1)

Custom SQL functions and Code First (EF 4.1) I'm using and code first approach. If I use attribute, what namespace should I specify? When I try to execute a LINQ query with such function the following...

Entity Framework (4.3) looking for singular name instead of plural (when entity name ends with "s")

Entity Framework (4.3) looking for singular name instead of plural (when entity name ends with "s") Here's my situation: I have been working on an ASP.NET MVC 3 application for a while. It has a datab...

How to pass multiple Expressions to OrderBy for EF?

How to pass multiple Expressions to OrderBy for EF? I am using EF 4.2, but I expect this would apply to EF 4 and 4.1 as well. I would like to pass an `IQueryable` and multiple `Expression>` to a metho...

what is the most reasonable way to find out if entity is attached to dbContext or not?

what is the most reasonable way to find out if entity is attached to dbContext or not? when i try to attach entity to context i get an exception > An object with the same key already exists in the Ob...

17 May at 15:39

Exclude a field/property from the database with Entity Framework 4 & Code-First

Exclude a field/property from the database with Entity Framework 4 & Code-First I will like to know that is there a way to exclude some fields from the database? For eg: ``` public class Employee { ...

Why re-initiate the DbContext when using the Entity Framework?

Why re-initiate the DbContext when using the Entity Framework? I don't know if there is a better way to use the `DbContext` because . So we are creating it each time we want to access the database. Kn...

EF4 Cast DynamicProxies to underlying object

EF4 Cast DynamicProxies to underlying object I'm using Entity Framework 4 with POCO template. I have a List where MyObject are dynamic proxies. I want to use the XmlSerializer to serialize this list, ...

Change db table name in EF4 (entity framework 4)

Change db table name in EF4 (entity framework 4) Does anyone know how to change the mapped db table for an entity in EF4 (entity framework 4)? Later edit: I think i've found the place where the table ...

Entity Framework: How to put multiple stored procedures in a transaction?

Entity Framework: How to put multiple stored procedures in a transaction? I did a lot search already but couldn't find a straight anwser. I have two stored procedures and they both were function impor...

Turn off EF change tracking for any instance of the context

Turn off EF change tracking for any instance of the context I have a context to a read-only database for reporting and I am writing lots of code, like this: Is there a way to set the `AsNoTracking` bi...

How not persist property EF4 code first?

How not persist property EF4 code first? How do I make non persisted properties using codefirst EF4? MS says there is a StoreIgnore Attribute, but I cannot find it. [http://blogs.msdn.com/b/efdesign...