entity-framework

POCO Support in the Entity Framework

While the application I am developing at the moment is written in .net 4.0 against the beta, I have largely been ignoring POCO support in the Entity Framework because I didn't need it. I'm starting to realize, however, that POCO support would be useful in my project. However, Google searches on POCO in the EF yield a lot of results about...

Machine.Specifications and Entity Framework Examples

I'm trying to find some best-practice examples (or any examples, actually) of using Machine.Specifications with the ASP.Net Entity Framework in an MVC project. Not having had much experience with Machine.Specifications, I'm keen to see what sort of tests other people find useful and whether there are any gotchas for using the EF-generat...

keep track of object changes in datagridview using the entity framework

I'm using a DataGridView to display EntityObjects from the .NET Entity Framework. how could I change the formatting of a row of the DataGridView if the corresponding EntityObject has been altered by the user, e.g. displaying the row in bold greetings ...

Entity Framework - DateTime in the where clause

I'm trying to convert this code from a stored procedure into a "LINQ to Entities" query: select * from myTable where venue_date + start_time <= @EndDate and dateadd(minute, duration * 24 * 60, venue_date + start_time) >= @StartDate As you can see there is some manipulation of dates. This sort of thing won't work because functions such...

Linq to sql VS Entity Framework VD NHibernate performance in an ASP.NET 3.5 Mashup style Application

I am tasked to build a web 2.0 style mashup application which consumes a lot of 3rd party webservices like youtube and twitter. There are also lots custom features which are going to be built using ASP.NET 3.5 and SQL Server 2008. Now I am looking for the right ORM for my needs. From a performance and ease of use standpoint can anyone su...

named connection not found (Entity framework problem)

I'm building multi-project Application where some UserControl, the user control has a Entitymodel object (myDBContainer db = new myDBContainer()), when i drop my user control on my a form i got the following designer error The specified connectionis either not found in the configuration, not intended to be used with the entityc...

Is it good practice to use Entity Framework in unit tests?

I'm writing NUnit tests for a service. I've decided to do this by sending direct SQL statements to the database instead of using the Entity Framework model so that I could be certain of the results, i.e. I am testing what is in the database and not what the Entity Framework tells me is in the database (e.g. it could be reporting a cache...

An entities that create entities using Entity Framework

How do you handle the case when an entity needs to create, in one of its methods, other entities? My problem is that since each individual entity doesn't have access ObjectContext object, that one with the AddToBlahs() methods, it cannot do it. For example, having a Site model that has a UpdateLinks() method that is supposed to create L...

'Generic' ViewModel

Using EF 4, I have several subtypes of a 'Business' entity (customers, suppliers, haulage companies etc). They DO need to be subtypes. I am building a general viewmodel which calls into a service from which a generic repository is accessed. As I have 4 subtypes, it would be good to have a 'generic' viewmodel used for all of these. Probl...

Internet Explorer lags w/ IQueryable datasource. Firefox and Chrome A-OK. Video proof supplied.

I'd like to say it's the query, but it isn't. Even when we go through it step-by-step, the queries finish without a hitch. Even the .DataBind() method doesn't APPEAR to cause the lag. Here's how I know it has to do with my IQueryable as the binding source: Old code: Call a stored procedure using SqlCommand and use SqlAdapter to fil...

one-to-one relationships in Entity Framework 4 v2 with POCO

I've been looking for an example about how to build an one-to-one relationship in EF4v2 with POCO's. I found a lot of examples that show only how to create one-to-many or many-to-many. Do you have any resource about it? ...

"At least one SSDL artifact is required for creating StoreItemCollection" Error with Entity Framework

I have recently been getting this error on my ASP.NET MVC project that uses the Entity Framework: At least one SSDL artifact is required for creating StoreItemCollection The error occurs when I try to query the database in a controller action. Has anyone seen this error before? It only occurs every once in a while for me but I am...

Entitiy Framework object tree loading

How to load in a following EF entities: image source: http://blogs.microsoft.co.il/blogs/idof/archive/2008/08/20/entity-framework-and-lazy-loading.aspx Let's say we have address id and we want to load address with person and the pets. How to do that? We can do that var address = contex.Addresses.Include("Peson").Where(add => add.Id...

Update a foreign key in Entity Framework

Hi! I have created a partial class of an entity for getting a foreign key property on it. public partial class Artikel { public int WarengruppenID { get { if (WarengruppeReference.EntityKey == null) return 0; return (int)WarengruppeReference.EntityKey.EntityKeyValues[0].Value; } ...

Only parameterless constructors and initializers are supported in LINQ to Entities.

While trying a sem-complex query to display some ListView content on the page I got stuck on the famous "Only parameterless contstructor and initializers are supported in LINQ to Entities" error. Here is the code I used ... I can't find a place where I initialized something inside the query with parameters .... protected void ArtistsL...

Number of members in conceptual type does not match with number of members on object side type.

I'm using .net framework 3.5 SP1. After adding a column to one table in Sql Server (as well as changing an existing column from allowing nulls to not nullable), I can no longer run my project without getting this error: The number of members in the conceptual type 'XBRLDimensionalModel.axis_t' does not match with the number of...

MVVM With EF, DataAccess design question

Hi all, First and foremost. Sorry about my English, i'm still learning :) I'm currently wrestling with the MVVM model. At the bottom, i have a database. On top of that sits my DAL which is bascily the ADO.NET entity framework. *Note that the different entities are also my business objects (since i include validation in them). On to...

Bind WPF control to SQL server through repository pattern

How can I bind a wpf control to a SQL Server property. Like say a Listbox <ListView> <ListView.View> <GridView> <GridViewColumn Header="Name"> <GridViewColumn Header="Date Assigned"> <GridViewColumn Header="Date Due"> </GridView> </ListView.View> ...

How to delete an asociated object in Entity Framework without having access to the object context

Having two models, Site and Link, where a site has many links, how do I delete a link from inside a method of Site, which doesn't have access to the object context? I've tried something like: public void DeleteFirstLink() { var link = LinkSet.First(); LinkSet.Remove(link); } but it seems that is not really deleting the link, ...

Entity Framework: Setting update timestamp

All of our database tables have UpdateUserID and UpdateTS. I'd like to have this set if my entity has changes. Is there a way I can have this update on the spot conditionally? If I manually set UpdateTS in code, then it will say that my entity has changed and will always update the object. ...