entity-framework

Adding existing entity to navigation property of a different entity

I'm using EF4 and I'm running into a problem when I try to do something that looks quite trivial to me. I have two entities, let's call them A and B. These entities have a many-to-many association between them with a navigation property on A that contains a list of related B entities. What I want to do is to add existing B entities to ...

How do I collapse all entities to just headers when editing an Entity Framework EDMX model in Visual Studio 2010?

Each block representing an entity has an icon to collapse it to its header (hiding all properties from the diagram) in the header's right-top corner. How do I collapse them all without clicking each one manually? ...

ForEach with EditorFor

I have got an Entity model which contains a collection of Message objects which are of the type Message which has several properties, including content, MessageID, from, and to. I have created an EditorTemplate for type Message, however, I cannot get it to display the contents of the Messages collection. There are no errors, but nothin...

ASP.NET. MVC2. Entity Framework. Cannot pass primary key value back from view to [HttpPost]

I pass a ViewModel (which contains a "Person" object) from the "EditPerson" controller action into the view. When posted back from the view, the ActionResult receives all of the Person properties except the ID (which it says is zero instead of say its real integer) Can anyone tell me why? The controllers look like this: public...

Binding DataGridComboBoxColumn to a one to many entity framework relation

I have two tables in the model, one table contains entries related to the other table in a one to many relations, for example: Table User ID Name Table Comments ID UserID Title Text I want to show a datagrid in a WPF window with two columns, one text column with the User name and another column with a combobox showing all...

extending an entity framework model

Hi, i want extend an entity framework model with a temporany attribute. I need it only in a mvc form. I don't need save it in the db. How can i do it? ...

Views does not import to Entity Framework

Hi, I have a few views in my database that im using in my ASP MVC-application. Now I am experiencing a very strange problem. There are 8 views in the database but even if I check them all in the Create Enity Data Model-guide only 7 of them are available as objects in the datacontext. If I try to import ONLY the view that gets left out ...

Classes to Entities; Like-class inheritence problems

Beyond work, some friends and I are trying to build a game of sorts; The way we structure some of it works pretty well for a normal object oriented approach, but as most developers will attest this does not always translate itself well into a database persistent approach. This is not the absolute layout of what we have, it is just a sa...

Entity Framework's object graph & Repository Pattern

The repository pattern typically has Get*() and Save() (or equivalent) methods for each object. How does this fit into the object graph in EF? Consider the following with lazy-loading POCO objects: // EF var orderItems = context.OrderItems.Where(oi => oi.Order.Id == 123); // Repository IOrderItemsRepository orderItemsRepository = new...

Use EdmFunctionAttribute without exposing Entity Framework dependency/implementation details?

Is there a good way to leverage EdmFunctionAttribute without introducing a dependency on The Entity Framework/System.Data.Entity.dll? I thought I could have an interface with a method and a concrete implementation that implements the method using EdmFunctionAttribute to map it to a database function. I have a context interface IMyConte...

How Can i change Tracking Information of object from ObjectContext to another??

I have an object which is added to an objectContext .. after some operation i need to pass it to another objectcontext of the same database but i always face this message : An entity object cannot be referenced by multiple instances of IEntityChangeTracker. i need to change tracking information be detach it from the old object and...

What's all the hype over objectsets in Entity Framework 4?

I am an intermediate user of EF in .net 3.5 and have recently moved to working with .net 4. One thing i keep coming across when reading various tutorials is the use of ObjectSets instead of ObjectQuerys and that they are a great new feature. What is so great about them? Please enlighten me. Kind regards, Kohan ...

Entity framework and database logic.

Hi all, i have a question that's being around for several years. As all you know entity framework is an ORM tool that tries to model the database to an object oriented access model. All the samples I've seen are quering directly to the database tables. So, which is the role of the views in the database now?. The views were used to model...

Execute a SQlite command with Entity Framework

Hi everybody, I use a SQLite database and Entity Framework (with .net framework 3.5). I'm trying to execute a simple SQL non query command to create a new table in this datase. My Entity Framework already contains the object model for this table : I just want to generate the corresponding table using a command. (By the way, there is ma...

WCF Data Services consuming data from EF based repository

We have an existing repository which is based on EF4 / POCO and is working well. We want to add a service layer using WCF Data Services and looking for some best practice advice. So far we have developed a class which has a IQueryable property and the getter triggers the repository 'get all users' method. The problem so far have been tw...

3 methods for adding a "Product" through Entity Framework. What's the difference?

Reading this MSDN article titled "Working with ObjectSet (Entity Framework)" It shows two examples on how to add a Product.. one for 3.5 and another for 4.0. http://msdn.microsoft.com/en-us/library/ee473442.aspx Through my lack of knowledge I am possibly completely missing something here, but i never added a Product like this: //I...

Followup: Table Per Concrete Type Performance/Scaling

This is a followup/post question to another question; as I have discovered a solution that has led me to a new problem. http://stackoverflow.com/questions/2802902/classes-to-entities-like-class-inheritence-problems We're building this game system, so to speak; and I am using Table Per Concrete Type concept to perform inheritance modeli...

Get unrelated entities in one trip to the database

Hello,, I have 3 entities that are not related to each other and I want to get all these entities in one trip to the database how can I do this ?? Thanks ...

setMessage for Zend_Validate_EmailAddress doesn't work

Hello everybody. I have a form and I want to set my custom errors in it. I am using Zend, and I have the following code... //Create validators $formMustBeEmail = new Zend_Validate_EmailAddress(); $formMustBeEmail->setMessage(array( Zend_Validate_EmailAddress::INVALID => "1. Invalid type given, value should be a string", Zend_...

How to order by column with null values last in entity framework

Does anyone know how to return an ordered list of strings with null values last? I have something like this: using(var context = new DomainEntities()) { var result = context.Users.OrderBy(u => u.LastName).ThenBy(u => u.FirstName); } My problem though is that this query returns null values before non-null values. Any thoughts? ...