entity-framework

MetadataException when using Entity Framework Entity Connection

This code: using (EntityConnection conn = new EntityConnection("name=ELSCommonEntities")) { conn.Open(); } Gives me the following error: Test method ELS.Service.Business.IntegrationTest.Base.ServiceBaseIntegrationTest.StartLoggingTestMethod threw exception: System.Data.MetadataException: Unable to load the specified metadata reso...

Entity Framework: Issue with lazy load "solution" (Not asking how to do lazy loading)

So basically I came up with a semi home grown solution to lazy loading by basically having generated property be private and have a public property that dealt with whether to load the generated property: public ChatRoom ParentRoom { get { if(!ParentRoomInnerReference.IsLoaded) { ParentRoomInnerReference.Load();...

.Net EntityFramework binding to gridview

For simplicity I am going to use Northwind as an example... I would like to have a databound DataView that displays "Order" information data from two different entities "Products" and "Order Details" I want to build a web form where when the user clicks on the screen to view a "Order" It would display a single databound Dataview that co...

How to keep Entity Framework and database aligned

Hi, in early development stages the database is subject to continuous changes. I'm toying around with LinqToSQL and in most cases the Entity Model is just a 1:1 representation of the DB. How can i keep the model up to date with the db changes? Thanks. ...

Entity Framework - Update entity with child properties.

I have an entity that has one child and I need to update it, but, in the TryUpdateModel method, it does not accept an strong typed object (accepts only a FormCollection), and when I try to update it, I get the following error. {"A relationship is being added or deleted from an AssociationSet 'FK__SG_Usuari__ID_Si__534D60F1'. With cardi...

Is there a way to get entity id-field's name by reflection or whatever?

Hi I am trying to get the ID field name (property name) of an entity, is it possible? User user= new User(); //User is an Entity string idField = ??????? //user.UserId ...

How to add/remove many-to-many relation with entity framework by entity key?

I tried: using (Entities e = new Entities()) { EntityKey key = new EntityKey("Entities.Users", "UserId", 20); User user = new User { EntityKey = key}; Role role = e.Roles.FirstOrDefault(); //role.Users.Attach(user); //throws (when uncommented...) InvalidOperationException: //The object being attached to the source ob...

Datagridview with ADO.Net Entity Framework: null values

Hi everyone, I have some problems with the Datagridview, a Bindingsource for the datagrid with a datasource of a ADO.net Entity Framework ObjectEntity called categorie. During runtime, and setting the BindingSource Controls property 'DataSource', I get this error message: "[ConstraintException] This property cannot be set to a null ...

ASP.NET MVC and Entity Framework: query persistance

Hi, I'm facing the following problem: in the controller I select the data I need and store it into the ViewData; using (Models.SkedruleEntities ctx = new Models.SkedruleEntities()) { ViewData["users"] = (from u in ctx.User select u); } In the View I try to read from the ViewData like this: <p> <%foreach(User user in (IEnumera...

What are the Java equivalents to Linq and Entity Framework

Having played with Linq (to SQL and Objects) as well as the Entity Framework from Microsoft recently, I was wondering what the non-.Net (specifically Java) equivalents are? ...

How do you build your LINQ queries?

It seems there are two ways to build queries -- either using query expressions: IEnumerable<Customer> result = from customer in customers where customer.FirstName == "Donna" select customer; or using extension methods: IEnumerable<Customer> result = ...

conditional include in linq to entities?

I felt like the following should be possible I'm just not sure what approach to take. What I'd like to do is use the include method to shape my results, ie define how far along the object graph to traverse. but... I'd like that traversal to be conditional. something like... dealerships .include( d => d.parts.where(p => p.price < 1...

ado.net entity framework using count in a where clause

Hi, I am trying to execute the following query but I get the wrong results back. foreach (var item in (from project in db.Projects where project.Id == pProjectId from task in project.Tasks from taskItem in task.TaskItems ...

[Entity Framework] Loading a huge entity tree with EF

I need to load a model, existing of +/- 20 tables from the database with Entity Framework. So there are probably a few ways of doing this: Use one huge Include call Use many Includes calls while manually iterating the model Use many IsLoaded and Load calls Here's what happens with the 2 options EF creates a HUGE query, puts a very...

Entity Framework context mock/fake

It should parse EDMX file and create a moch/fake to use in Unit tests. The easiest integration would be by using T4 that we already have in VS IDE. Has anybody seen it on the web? Or is maybe writing it on their own? Or is there an OSS in progress doing this? Anybody? ...

Any tips on avoiding code Duplication on this abstraction?

Hi, So I'm building an App using the Entity Framework on top of SQL Compact Edition. I didn't like the idea of using the Entites as my business objects so I've been building a layer (I've called it ObjectModel layer, prob not the best terminology) in-between that will take my plain objects, use them to populate and save the entities. And...

ASP.NET MVC, EF, 'IsReference' property specified was not found

Hi Using Entity Framework, I suddenly get this strange error after publishing my asp.net mvc project onto my Win2003 server: [CustomAttributeFormatException: 'IsReference' property specified was not found.] The error occurs when I need to update or delete an entity. I haven't changed anything (and yes, it's actually true :-) in m...

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information

I have developed an application using Entity Framework, SQL Server 2000, VS 2008 and Enterprise Library. It works absolutely fine locally but when I deploy the project to our test environment, I am getting the following error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more informat...

What is the best way to compare two entity framework entities?

Hi All, I want to know the most efficient way of comparing two entities of the same type. One entity is created from an xml file by hand ( ie new instance and manually set properties) and the other is retvied from my object context. I want to know if the property values are the same in each instance. My first thoughts are to generate...

Entity-Framework: How to create a model from a disconnected dataset?

Using EF, is it possible to create the model from a disconnected dataset? Keep in mind that there is no "database", only a dataset. ...