entity-framework

Best practice entity validation in ASP.NET MVC & ADO.NET Entity Framework

Hi, i am using ASP.NET MVC & ADO.NET Entity Framework in a project. I want to add validation logic to my entities via partial classes. It works similar like shown in the NerdDinner.com ASP.NET MVC Application which is using LINQ2SQL. The main difference is, that i have to use the"OnPropertyChanging" event instead the "OnValidating" like...

Entity Framework: How to databind to a treeview

I am trying to databind my entity object to a WinForms treeview control but not really having much luck. I have an entity "Person" and I have bound the treeview to the surname of the person which has automatically created a "personBindingSource". In the load event of the form I am calling: ObjectQuery<Person> orderQuery = context.People...

Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types

I wrote a method to allow for an Expression to be passed in for the orderby clause, but I ran into this problem. Unable to cast the type 'System.DateTime' to type 'System.IComparable'. LINQ to Entities only supports casting Entity Data Model primitive types. Basically the expression is this: Expression<Func<K, IComparable>...

Entity Framework: equivalent of INSERT OR IGNORE

I'm using a database as a kind of cache - the purpose is to store currently known "facts" (the details aren't that interesting). Crucially, however, I'd like to avoid inserting duplicate facts. To do so, the current data access code uses insert or ignore in many places. I'd like to use the entity framework to benefit from it's managea...

Issue Returning Entity Framework 4.0 Entity from a WCF REST Service

I'm trying to return an EF object from a WCF REST service. It works fine when I do not eagerly load any child objects but once I do, I get a 404 error when I try browsing the service using Internet Explorer 7.0. ...

How to make Entity Framework cache some objects

I'm using Entity Framework. In my database are stored persons and country of their origins. When I'm loading a person object I wan't to know what is the place each person originates. Is there a way to cache list of countries so that there wouldn't be unnecessary requests. ...

ADO.NET Entity Framework - Pre-Generate Views -

We are using ADO.NET Entity for our ASP.NET application. I have read that the pre-generated views improves the performance. Referred to the blog post, http://blogs.msdn.com/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx, I generated the views. The namespace & classes generated as namespace Edm_EntityMappi...

Entity framework: ObjectContext get generated SQL change script?

Is there a way to get all the SQL change script of the object context? Note: I am not talking about ObjectQuery.ToTraceString(); ...

How do I correctly bind child entities in a DataGridView?

I have a DataGridView bound to an entity framework object called "Person". All the main fields of person such as Name etc show correctly, but the fields that are referenced to child tables (e.g. "Place of Birth") only show the entity name/type in the datagridview. How do I navigate through to correctly show the values of child entities ...

Subsonic 3 VS Entity Framework

Anyone worked with Subsonic3 and Entity Framework here who can tell me the pros and cons? This is my first time attempting to try these. Subsonic is easy to setup so as the Entity Framework. I am not sure if Entity Framework works with other databases as SubSonic does like MySql PGsql etc...? I read this post (http://www.timacheson.com/...

What problems have you had with Entity Framework?

We have used Entity Framework on 2 projects both with several 100 tables. Our experiance is mainly positive. We have had large productivity gains, compare with using Enterprise Library and stored procedures. However, when I suggest using EF on stackoverflow, I often get negative comments. On the negative side we have found that there ...

Dynamic Object Properties in a MVC Helper on a Entity Framework object

I am new to vb9 and the .NET MVC. I want to build a MVC helper function for which I pass a Entity Framework object and have it build a select. Generally speaking I tried something like this: Public Function RenderSelect(ByVal helper As HtmlHelper, ByVal sSelectName As String, ByVal aItmes As Array, Optional ByVal sTitleKeyName As Strin...

Entity Framework - Detach and keep related object graph

Hi, I've just started using Entity Framework rather than my normal NHiberante to see how EF works and so far I'm having lots of problems but one in particular is detaching an object and keeping the related child objects. I bought the O'Reilly Entity Framework book which tells you "yes entity framework by default doesn't keep the object ...

best practise/way for master detail / multi table Insert in Entity Framework

My table structure is this Orders ------ Id int identity OrderDate smalldatetime OrderStatusid tinyint Products -------- Id int identity Name varchar(50) OrderDetails ------------ Id int identity OrderId int (fkey) ProductId int (fkey) Amount decimal Rate decimal I am trying to an insert operation using Entity Framework using the c...

Use tables from 2 different databases - entity framework

Hello, I have a model got from a sql 2008 database, now i need, in the same model file to create a entity that represent a user-base from another database. How I can do this in the same model and avoid creating a database view. ...

Including navigation properties from Entity Framework TPH classes

I've got an EF hierarchy that (dramatically simplified) looks something like this: class Room { EntityCollection<Session> Sessions; } class Session { EntityCollection<Whiteboard> Whiteboards; EntityReference Room; } class Whiteboard { EntityCollection<WhiteboardShape> WhiteboardShapes; EntityReference Session; } abstract class Whiteboar...

How do I add ROW_NUMBER to a LINQ query or Entity?

I'm stumped by this easy data problem. I'm using the Entity framework and have a database of products. My results page returns a paginated list of these products. Right now my results are ordered by the number of sales of each product, so my code looks like this: return Products.OrderByDescending(u => u.Sales.Count()); This returns...

ADO.net Entity Framework: Update only certian properties on a detached entity

I want to update an entity without loading the entity from the database first. I've accomplished this but only by knowing all of the entities properties and then using the "attachto" method. My issues is i don't want my app to need to remember all of the properties. Example: Dim customerEntitiy As New shopper customerEntitiy.shopp...

How would I uniquely identify an entity in Entity Framework?

I'm using the Entity Framework as my ORM for an ASP.Net (webforms) application. Suppose I had a "list/detail" set of pages in my application, when you click on a row in the list page I would want to pass an ID of some type for that row to a detail page, which I'd then use to load the row from my data layer. In my specific case, the pri...

EF ObjectContext, Service and Repositry - Managing context lifetime.

I am fairly new to the MVP and the Entity Framework world so bear with me. I currently have a View + Presenter combination, the view has two events Edit and Delete and the presenter just listens for these events. I also have a service object and repositories set up. The service layer takes some repository implementations which take an...