entity-framework

DataLayer of a new Application: MyGeneration and/or Entity-Framework

The platform is ASP.Net 3.5sp1, with an Oracle db. We've considered both MyGeneration and Entity Framework for time and convenience in the DataLayer (and maybe some base classes in the Business Layer). My questions are: 1) Any pros and cons of using Entity Framework vs MyGeneration? 2) Any thoughts on using MyGeneration to generate...

Model class image disappears on mouse-over

I have just added an Entity Framework model to my console project in VS 2008, but when my mouse pointer moves over the only class in the model, in the model designer, the graphic for that class becomes invisible. Anyone else had this problem? ...

Create a record where the Model inherits from another Model

How do I set a models reference property correctly? I have a Model called Platform which has a navigational property to a model called Service. The issue I am having is with setting the value of platformToCreate.Service. Here is a screenshot of the Platform table: Here is a screenshot of the EDM: Code: [ValidateInput(true)] ...

Entity Framework - Association From Derived Entities

Hi, I'm using the TPH (Table per Hierarchy) technique to map a set of entities. DB Schema: UserGroupLabelSpreads table having a "UserId", "GroupId" and "LabelId" nullable fields with some additional common fields. DAL Objects: - UserGroupLabelSpread abstract class. - UserSpread with a discriminator having only non-null UserId. - GroupS...

ADO.Net Entity Framework and dynamic order by

I currently have the below code to fetch data from my Entity framework model. return db.Tasks.Where(t => (t.TaskStatuses.TaskStatusId.Equals(currentStatus) | currentStatus == -1) & (t.Projects.ProjectId.Equals(projectId) | projectId == -1) & (assignedToGuid ...

How do you use hiearchy datatype with ADO.NET Entity Framework?

Hi, I'm trying to model a hierarchy using the new hierarchy data type in SQL Server 2008. When I move the table into my EF model, the hierarchy column doesn't show up as something that can be mapped or as a property in the entity. Because I'm using ASP.NET MVC, I'm using the EF framework as the primary way to access data. Any ideas? ...

Searching free accomodation

I need help with a query? I have 2 tables reservations & units among others. Table reservations has columns ResId,rfrom(datetime),rto(datetime),status(int),UnitID(foreign key). Status 2 means its confirmed. I need to get all free units in requested period, query needs to return only that units for which there aren't confirmed reservatio...

problem with a Many to many relations in Entity framework

I have 3 entities -Direction -City -GeoPosition each Direction have a Geoposition, and each City have a collection of Geopositions (this represent a polygon) I have 5 tables -directions -cities -geopositions -directionsgeopositions -citiesgeopositions and EF entities is this each entity have function imports for insert, update, and...

How to partially migrate a database to a new system over time?

We are in the process of a multi-year project where we're building a new system and a new database to eventually replace the old system and database. The users are using the new and old systems as we're changing them. The problem we keep running into is when an object in one system is dependent on an object in the other system. We've b...

ado.net entity data model parent child relationship

Scenario I am playing MVC NerdDinner project and using ado.net entity data model instead on 'dbml' I have 2 database tables Dinner & RSVP where RSVP contains DinnerID as foreign key from Dinner table. Now when I am accessing a particular record from Dinner table, it returns a dinner object with RSVP property but there are no data with ...

A more concise syntax in C# constructor?

I have a constructor something like the following: using Microsoft.Data.Extensions; public class Complaint { public int Id {get; set;} public int Transcript {get; set;} //... etc. ... Lots more properties public Complaint(int id) { var command = dataContext.CreateStoreCommand( "dbo.stp_Complaint_Get"...

Temporary Entities with Entity Framework

I have an EntityObject named Pathway which relates directly to data in the pathway table. My database also stores rules for Pathway customisations. What I would like to do is create a Pathway object in my code that is the resultant of the Pathway + PathwayCustomisations. The resultant should never find it's way back to the database, it i...

Entity Framework: Doing large queries

Hi, I'm probably addressing one of the bigger usability-issues in EF. I need to perform a calculation on a very big part of a model. For example, say we need a Building, with all of its doors, the categories of those doors. But I'd also need the windows, furniture, roof etc. And imagine that my logic also depends on more coupled table...

Entity framework Calling 'Read' when the datareader is closed

Hi, I have had a breakdown on my webhost. Now finally it is up again, and I have yet to know what the technicians fixed. The problem is now I receive the error: Calling 'Read' when the data reader is closed is not a valid operation. Description: An unhandled exception occurred during the execution of the current web request. Please rev...

How to get ObjectResult from Entity Framework using a list of Identities

I have a HashSet of Identity values that I need to use as the query values to return a ObjectResult from the Entity Framework Here's the HashSet: HashSet<int> officeIds = new HashSet<int>(); Here's the query that I'm trying to run more or less: ObjectResult<FilingOffice> offices = ctx.FilingOffice.Where(office => office IN officeIds...

Entity Framework error - "The EntityContainer name must be unique"

We have a solution which consists of two projects - a console application project and a web application project. Each of these has an identical in schema, but differently named .edmx file used to access the same database. The console application runs as a scheduled task on the same server as the web application is hosted. The web applic...

Entity Framework Loading MultiLevel Associations

I currently have a database that consist of many linked objects. Simplified with less objects: Song => Versions => Info || \/ Data Now I understand that I can eager load all these objects when using db.Song.include("Versions.Data").Include("Versions.Info").ToList(); However, when I just want 1 song wi...

Force Entity Framework to ignore all foreign keys during class generation

Hi All, I am using the Entity Framework just to create classes that can be mapped to database tables. We have our own data access layer that I need to go through, which is why I'm only using the generated classes. I would like the entity framework to generate foreign keys as properties instead of classes. So, basically, when it gener...

EntityCollection<TEntity>.Contains(...) returns false for an entity queried out of the EntityCollection.

Hi I have the following code snippet. // Here I get an entity out of an EntityCollection<TEntity> i.e ContactSet. Entity is obtained and not null. ProjectContact obj = ((Project)projectDataGrid.SelectedItem).ContactSet .Where(projectContact => projectContact.ProjectId == item.ProjectId && projectContact.ContactId == item...

Entitry Framework Add To Intersection Table

Hi Every one, I have just started jumping into EF and cant seem to do something that seems simple. Here is my question and supporting info. Any help or suggestions will be greatly appropriated. I have a user table and a group table. Between these is a UserGroups Intersection table to allow a user to belong to any number of groups. T...