entity-framework

EntityFramework throws AmbiguousMatchException

The setup: EntityFramework POCO with proxies (+LazyLoading) Component and Part classes both implement IDataErrorInfo (if this is necessary). The following code throws exception: // Context is a singleton here Context.LoadProperty<Part>( partEntity, (e) => e.ChildComponents, MergeOption.OverwriteChanges); The ambiguous p...

LINQ to Entities - Where IN clause in query

Possible Duplicates: Linq to Entities - Sql IN clause How to implement SQL in in Entity framework 4.0 how can I add WHERE IN statement like... SELECT * FROM myTable WHERE ID IN (1,2,3,4,5) in entity framework ...

In EF4 Code first Collection are not lazy loading?

Using Microsoft Visual C# 2010 Express, Entity Framework Feature CTP4. I tried EF4 with code first with something small based on Scott Gu's blog. But it seems that collections are not initialized when retrieving an entity. I get a null reference exception when adding a product to a category. In all the examples I've seen, the collection...

Mapping of stored procedures is all-or-nothing in Entity Framework? (FunctionMapping)

I got the error Cannot find the InsertFunctionMapping for EntityType 'xxx' in the mapping file. Which is fair enough because it is true. But that is because I am happy with EF doing inserts for me. I simply want to override the delete function. I thought that was one of the improvements with EF4? Or is it just that it will bu...

Entity Framework on Windows 7

Our C# projects are developed in Windows XP with visual studio 2008 SP1 with .Net 3.5. We use Entity Framework with Sybase database. One of the sub-projects sharing edmx file with the main project. It works fine for long time. Now we are migrating our applications to Windows 7. we found that sub-project stopped to work for us, couldn't...

Prepared statements in Entity Framework

How can I run a prepared statement against a database and have the returned rows automatically attach to the entity framework data context? Essentially, how can I achieve the same functionality of ObjectContext.Execute except using a prepared SQL command. ...

Maintenace tasks under Entity Framework

Hello: After deploying a complete application using Entity Framework (EF) and LINQ, the next things can happen then with the data in a "database which previously was included/mapped to EF in the aplication": Create new tables and include into EF Delete existing tables from the database that were previously included in EF Include new f...

With entity framework's self tracking entities, can I perform an explicit load?

I wish to return a graph for a "Business" entity. The Buiness entity has a collection of "Contacts". So I basically want this: ctx.Business.Include("Contacts").Where(b => b.BusinessID == id).Single(); The problem is I don't want ALL the contacts for the business. Just those that have a ContactTypeID = x. How can I accomplish this? I ...

Incorporate Triggers Into the Model

Hi All, I have created a data model with in EF 4.0, however I am not sure how I can capture things like Triggers in this model so that if others were to deploy it the Tables, Views, Triggers, etc would go along with it. Is there a way to pull triggers into the model build? Thanks! --B ...

Entity Framework - Is there a way to reorder properties in the EDMX designer?

I'm using Entity Framework's model designer to design the model for a new project. Adding properties is relatively easy, however they're always appended to the entity. Is there a way to reorder the properties once they've been added? This is quite annoying! ...

Entities as views of a table.

Is it possible to create multiple entities as 'views' of one master table? Let me explain. Lets say we have a very large table called Foo in a database which schema we're not allowed to alter. Foo ( Key1, field1, field2, field3, field4, field_n ) We want to create 3 updateble entity types from Foo. FooLite ( Key1, field1 ) FooAlt ( ...

EF DataContext selecting unsaved objects

I am trying to implement an UnitOfWork type pattern where one DataContext is used over a short group of related methods and only at the end do I save the changes. However, I have found that entities added to the ObjectContext do seem to be available for reselection unless I SaveChanges, which is what I am trying to avoid. Can someone tel...

Calling user defined functions in Entity Framework 4

I have a user defined function in a SQL Server 2005 database which returns a bit. I would like to call this function via the Entity Framework. I have been searching around and haven't had much luck. In LINQ to SQL this was obscenely easy, I would just add the function to the Data context Model, and I could call it like this. bool resul...

EntityFramework - changing multiplicity from 1 to 0..1 changes FK location

I have a model: Customer - Address. Customer inherits from Person (if this is important). So, the idea here is that there should be a nullable FK from Customer to Address. Is it at all possible? I am wondering because if the relationship is 1-1 then I can get the FK to Customer table. Yet if I change the multiplicity of address to 0..1 t...

Entity framework, LINQ or another framework?

We are working on a large C# 3.5 project that requires a centralized database. The database itself is small both in number of tables and in the size of those tables. Typically, the user will pull information from the database and work on a local copy. My assumption is that the local copy will be in XML but this is not a requirement. In s...

Entity Framework - Binding WPF Tree view control

In Service Category table, ParentCategoryId is the ServiceCategoryId and that is the parent category, there can be nth level hierarchy of my categories, so I need to present this using Tree View Control. How can I do this? Thanks ...

VS 2008, .net 3.5 project in VS 2010: Could not load type ...EntityDesignerBuildProvider

Hello! I am trying to move a project from VS 2008 to VS 2010. The project upgrade wizard completed fine, but the project does not compile. It says: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config(129): error ASPCONFIG: Could not load type 'System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider'. I have ch...

How to identify associations flagged as Cascade Delete

I am using EF 4.0 and in my entity data model I have several relationships where I have a 1-to-many associations and have the assocation flagged as Cascade OnDelete. Is there a way to programatically identify these associations for an entity type T? One option I thought of was identifying these associations and in my T4 template annotat...

Entity Framework - return the database value or create a new instance (nav property)

My setup is as follows: Entity Framework POCO (+ proxies & lazy loading). And a Person class with reference to Address: public class Person { private Address _address; /* Navigation property */ public virtual Address Home { get { return _address; } set { _a...

Entity Framework considerations for ASP.NET applications

I've created a business layer with a database model to be used in an ASP.NET application. I've used Linq To SQL Classes in Windows Forms before but using ORMs in per-request web applications is foreign to me. I've a few things I couldn't figure out and I'd appreciate if anyone give me any insight.. My BLL has static methods like GetReco...