entity-framework

Many-to-many relationship with surrogate key in Entity Framework

Entity Framework magically interprets the following table structure as a many-to-many relationship. table foo (int id) table foo_bar (int foo_id, int bar_id) table bar (int id) But if the join table has any additional fields it will instead be interpreted as two one-to-many relationships. I am using a database in which the join table...

ADO.NET Entity Framework generates unexpected, problem INSERTs

I need some help understanding the ADO.NET Entity Framework. I'm trying to represent and manipulate hierarchical data in a WPF TreeView control with the ADO.NET Entity Framework. Each of these Things has a single parent and zero or more children. My "delete" button... Private Sub ButtonDeleteThing_Click(...) db.DeleteObject(Di...

Good Entity Framework sample applications?

I am looking for some good asp.net sample applications which use Entity Framework. I saw a couple apps for NorthWind (one was MVC based). Looking for one with is more sophisticated than the simple apps at MSDN (HRSkillsCombined, CourseManager,AdWksSalesWinDataBind, ResearchCollaborationAssistant). Possibly using Entity Inheritance, mult...

Pros and cons of using EntityDataSource vs ObjectDataSource in Entity Framework?

What are the pros and cons of using EntityDataSource vs ObjectDataSource in Entity Framework asp.net based apps? ...

Entity Framework Error on Model Creation

I am a newbie to the Entity Framework. I am trying to generate a model from my database and I get the following errors: '_Content' is already declared as 'Private _Content As Integer' in this class. 'OnContentChanging' cannot be declared 'Partial' because only one method 'OnContentChanging' can be marked 'Partial'. 'OnContentChanged'...

ADO EF - Errors Mapping Associations between Derived Types in TPH

Background: I am writing a data access library using the ADO Entity Framework in Visual Studio 2008 SP1 using the .NET Framework 3.5 SP1. I am trying to create associations between two entities that are both derived from an abstract type. I am representing both entity inheritance hierarchies using Table Per Hierarchy (TPH) which means...

Entity Linq - Retrieve record and only the first child record in a one to many relationship.

I have an entity called "Requests" which has a navigation called "StatusHistories" I need to retrieve all of the Requests where the last StatusHistory is "Open" StatusHistory has the fields StartDate (the highest one of these would be the last StatusHistory) Status (for this presume status contains the string "Open" or "Closed") Recor...

Entity Framework Many To Many Issues

I have a Many To Many Relationship using a linking table which contains additional information. 3 Entities ,LHS, RHS, LHSRHS LHS 1 - * with LHSRHS RHS 1 - * with LHSRHS I use the designer to generate EDMX based on the tables I have 2 issues 1) If a create all 3 entities (new ones) link them up and try to persist i get a FK violation as...

Navigating trees with LINQ to entities

I have a table called Area, that stores areas in a hierarchical manner. There is an Id and a ParentId column in the table. The ParentId is linked with a foreign key to the table's Id column. When I generate the EDM, I get two navigation properties, Area1 and Area2. How am I supposed to get back a tree structure of my areas, and navigate...

Local storage layer for Entity Framework?

I've been implementing a SQLServer 2005 backed EF solution for the business app I'm working on, and It's been working out fine. I'm encountering a problem in that I want to allow the user to work without a database at all while using the same entities. I don't want to go to local databases for portability reasons. Also, it's easy to se...

linq to entities inheritance query problem.

I'm trying to perform a linq to entities query on a table that's inherited using Table per Type. The problem I'm having is that I can't get at the properties on the Inhertied table only the properties on the Base Table. var qry = from i in _DB.BaseTable where i is catalogueModel.InheritedTable // Field Doesn't Exist // && i.InheritedTa...

Xml vs. Database for application configuration

My application configuration is very hierarchical and fits nicely into a single XML. Soon (YAGNI, Yeh) parts of this information will be consumed by other applications remotely, which calls for a database. So, I went into designing DB tables and mapping them back to my application's class hierarchy (using EF). however it became a mainte...

Entity Framework - Table Per Type Inheritance - Existing Database

I want to implement Table Per Type inheritance with Entity framework for an existing database. The database: The inheritance for ImageParagraphs works perfect, but I am not able to make a Table Per Type inheritance with LinkListParagraph because of the different primary keys (ParagraphID; ParagraphID+LinkID): Error 1 Error 3003:...

How do I navigate through multiple relationships using LINQ to Entities?

I'm just starting out with LINQ to Entities, and I'm trying to replicate a search we currently do in a stored procedure as a LINQ to Entities query. However, I can't seem to figure out the correct way to query properties of entities more than one "join" away from the starting point of my query. For example, say I have tables Campaign, ...

LINQ to Entities for subtracting 2 dates

I am trying to determine the number of days between 2 dates using LINQ with Entity Framework. It is telling me that it does not recognize Subtract on the System.TimeSpan class Here is my where portion of the LINQ query. where ((DateTime.Now.Subtract(vid.CreatedDate).TotalDays < maxAgeInDays)) Here is the error I receive in the VS.NET ...

Is there an in-memory provider for Entity Framework?

I am unit testing code written against the ADO .NET Entity Framework. I would like to populate an in-memory database with rows, and make sure that my code retrieves them properly. I can mock the Entity Framework using Rhino Mocks, but that would not be sufficient. I would be telling the query what entities to return to me. This would ne...

Function Imports in Entity Model with a non-Entity Return Type

I have a stored procedure in my Entity Data Model and added it to the function imports. Problem is ... Visual Studio generates the function code in the model's code-behind if and only if I specify the return to be an entity type. Scalar and null return types do not work. Visual Studio does not generate the function code when I choose ...

Entity Framework, Dynamic Data and Versioning

I'm in the process of looking around at options for a back office tool. On the face of it the tool is simple CRUD so I was immediately attracted to Dynamic Data on top of Entity Framework (we're definitely a Microsoft shop!). The problem is that future requirement is to support versioning. By this I mean : User performs a series of ...

How can I manually add a compound association in entity framework?

This seems like a common case, but for whatever reason, I am stymied by EF's weak editor. I have two tables, like so: Table1 ( Column1 int, PK Column2 int, PK ) Table2 ( Column1 int, PK, FK Column2 int, PK, FK Column3 int, PK ) Now, the database (out of our control) does not have foreign key constraints. In this example, Table2 is s...

Building a SSRS 2008 off an EDM

Can someone please outline the process of building a SQL Server Reporting Services 2008 report based on a ADO.Net Entity Framework Entity Data Model? If you know of any example, please point me to it. Thank you! ...