entity-framework

What is the proper way to create a recursive entity in the Entity Framework?

I'm currently using VS 2010 RC, and I'm trying to create a model that contains a recursive self-referencing entity. Currently when I import the entity from the model I get an error indicating that the parent property cannot be part of the association because it's set to 'Computed' or 'Identity', though I'm not sure why it does it that wa...

EntityCollections setting an EntityReference.EntityKey to populate the Collection

Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder to eliminate the need for querying the database ever time I add an Entity Reference. Now I want to do the same thing for an Association (EntityCollection) but im not sure where to start. below are the details of what I am trying to d...

MVC 2 and Entity Framework - Should I put Entity classed in seperate layer?

I'm looking at ASP.NET MVC 2 and Entity Framework for a project I'm beginning. Whilst I previously used .NET lots up until around the time 3.5 had just come out, I've not really been so inspired to keep up over the last few years, so am a bit out of the loop. Anyway - I'm trying to find some information on preferred solution setup when ...

Entity Framework Update existing foreign Key reference to another

Hi, I have two tables Team_DATA and Driver_PROFILE_DATA in an SQL database. For every driver_profile there can be many teams. So there's a one-to-many relation on the driver_profile to team_data table. I want to update a team_data foreign key reference in the Driver_profile table of an already existing record to another team_data rec...

ms entity framework delete child onject

i have 2 tables without any cascade deletind. i wont to delete parent object with all child objects. i do like this //get parent object return _dataContext.Menu.Include("ChildMenu").Include("ParentMenu").Include("Pictures").FirstOrDefault(m => m.MenuId == id); //then i loop all child objects var picList = (List<Picture>)menu.Pictures.To...

Error "Index was outside the bounds of the array" for EDMX

OK. When I'm actually trying to Update the modal, some additional keys are getting added. For solving that, I've opened the edmx file with xml editor. then removed the additional keys. Then the edmx build successfully. But the problem is when I do 'validate' the edmx, then visual studio throws strange error "Index was outside th...

Entity Framework - extra dynamicly calculated properties for business objects/models (ASP.NET MVC)

Let's say that I have Customer model with following fields: Id, FirstName, LastName. I want to present list of Customers in List View. For this I use my service method which return List to iterate in view. But now I want also to display some additional information for each customer, for example credit. This information is not stored in ...

Using LINQ to Entity results with MVVM

I am getting started with Entity Framework using EF4 in VS 2010 RC. So far, I have done some simple console apps where I create an EDM, query it using LINQ to Entities, and output the results to the console. Now I am building a demo WPF app to learn how to integrate EF4 with WPF. I use MVVM in my WPF apps, where each view (more or less)...

C# Report Wizard and Entity Framework.

This is probably quite simple, but I just don't know how to do this... I have a reasonable complex SQL Server database containing multiple schema's for data and a generic view to provide information over all those views. (Basically, it lists all extended properties of all schema's.) This setup cannot be changed since every schema is spe...

How to map Stored Procedures with EF4 ?

Is it possible to map stored procédures whit EF 4 using T4 templates ? I have searched and I conclude that it is not possible yet. It exist some methods like Edm.SourceComplexTypes(), Edm.SourceAssociations(), Edm.SourceEntities() but nothing about stored procedures ... Someone have any answer ? Thanks. ...

Wide and narrow versions of an entity mapped to one table in Entity Framework

In some scenarios I need a "wide" version of an entity with many properties (say FullCustomer) while in other scenarios it's enough with a "narrow" version with few properties (say MiniCustomer), how could I map these two entities, FullCustomer and MiniCustomer, to the same Customer table in the database? Furthermore, I need to be able t...

Entity Framework doesn't like 0..1 to * relationships.

I have a database framework where I have two tables. The first table has a single column that is an identity and primary key. The second table contains two columns. One is a varchar primary key and the other is a nullable foreign key to the first table. When adding the tables to the model I get the following validation error: Condition...

entity framework inserting a many-to-many relationship between two existing objects while updating

I'm trying to do this: using(var context = new SampleEntities()) { User user = select a user from database; //Update user's properties user.Username = ... user.Website = ... //Add a role Role role = select a role from database //trying to insert into table UserRoles which has columns (UserID, Role...

Creating new Entities from Stored Procedure

I have a stored procedure that retrieves existing rows from a table and also creates includes new rows that match the table definition and mapped entity (.net 3.5 entity framework). These new rows are not written to the database in the stored procedure. The stored procedure executes, but the new rows that were created will not load the ...

.Net Entity Framework SaveChanges is adding without add method

I'm new to the entity framework and I'm really confused about how savechanges works. There's probably a lot of code in my example which could be improved, but here's the problem I'm having. The user enters a bunch of picks. I make sure the user hasn't already entered those picks. Then I add the picks to the database. var db = ...

Does WPF break an Entity Framework ObjectContext?

I am getting started with Entity Framework 4, and I am getting ready to write a WPF demo app to learn EF4 better. My LINQ queries return IQueryable<T>, and I know I can drop those into an ObservableCollection<T> with the following code: IQueryable<Foo> fooList = from f in Foo orderby f.Title select f; var observableFooList = new Observa...

SOLVED: deploying applications that use LINQ to Entities.

HI COMUNITY!!!! I want to use L2E since it s very convenient to my company's apps, I created a demo project, the demo does run on every machine but when I, lets say, press a button that has some code that uses the entity I get this error: specified store provider cannot be found in the configuration, or is not valid. note that I get ...

Opening an SQL CE file at runtime with Entity Framework 4

I am getting started with Entity Framework 4, and I an creating a demo app as a learning exercise. The app is a simple documentation builder, and it uses a SQL CE store. Each documentation project has its own SQL CE data file, and the user opens one of these files to work on a project. The EDM is very simple. A documentation project is ...

Error while updating Database record with Entity Framework on ASP.NET MVC Page

Hi I have an ASP.NET Page that updates registered User Address Details for a selected record. Below is the Update method that i am calling from Controller. When i am calling ApplyPropertyChanges method, I am getting the below error. Did anyone run into the same error while updating the record with Entity Framework. Appreciate your re...

Inheritance with POCO entities in Entity Framework 4

I have a Consumer class and a BillableConsumer : Consumer class. When trying to do any operation on my "Consumers" set, I get the error message "Object mapping could not be found for Type with identity Models.BillableConsumer. From the CSDL: <EntityType Name="BillableConsumer" BaseType="Models.Consumer"> <Property Type="Stri...