entity

ObjectContext.SaveChanges() violates primary key, throws UpdateException?

Paraphrasing from this MSDN documentation ... An INSERT statement is generated by the Entity Framework and executed on the data source when SaveChanges is called on the ObjectContext. If the INSERT operation succeeds, server-generated values are written back to the ObjectStateEntry. When AcceptChanges is called auto...

Entity framework 4 in a 3 layered environment

I came across the following article and was able to setup a functional test application. Pretty straight forward although the comments related to the article gives me second throughts about using this approach. Opinions? http://aspalliance.com/1943_ASPNET_40_and_the_Entity_Framework_4__Part_4__A_3_Layered_Approach_to_the_Entity_Framew...

EF4, Lambda, Repository pattern and DTOs

I have a semi complicated question regarding Entity Framework4, Lambda expressions, and Data Transfer Objects (DTO). So I have a small EF4 project, and following established OO principles, I have a DTO to provide a layer of abstraction between the data consumers (GUI) and the data model. VideoDTO = DTO with getters/setters, used by th...

Creating an AssociationSetMapping for MySQL with the Entity Framework Designer?

I am trying to build an Entity Framework model for my database schema using EF4 and Visual Studio 2010. Since I am stuck using MySQL as our database (for now), I pretty quickly discovered that since MYISAM tables don't support foreign key constraints, the designer does not have any way to automatically create all the associations for you...

How do I get Entity Framework to only update the Properties modified in the SQL generated?

I am using Entity Framework with the Self-Tracking Entity T4 templates, which by default will generate a SQL Query setting all the properties on the Entity in an UPDATE statement. I only want an UPDATE statement that contains the properties modified. I modified the T4 Template as specified in the book: Entity Framework Recipes: A Probl...

Getting Entity Framework Error: Invalid object name 'Navigation'.

I have an Entity Object called Navigation stored in a Database called Navigations. When I save the Entity calling context.SaveChanges(); I get the error Invalid object name 'Navigation'. I have removed the model and added it back in but with no change. Does anyone have any ideas? ...

Java Entity Beans are not deleting rows from database; only from JTable

I am using Entity bean in NetBeans, to develop some master/detail forms. When I run the forms, I click the Delete JButton, and the row dissapears from the JTable. But when I click on "Reload", the supposedly deleted row shows up again. I don't know why is this happening; why does the Entity doesn't erase all the way to the database ta...

.NET/MVC2 data caching using Entity Data Models

I am having a strange caching problem and I believe it might be related to the fact that I am using a Entity Data Model as my data source. The problem is that I can update the database directly and it doesn't reflect on the actual site until I republish the project. The data does display properly when viewing the project locally. The o...

Is it possible to use different inheritance strategy for subclasses?

I currently have a mapping problem and no idea how to solve it. Here is what we currently have. AbstractEntity is a @MappedSuperclass ExtendedEntity is an abstract @Entity extending AbstractEntity with InheritanceType.TABLE_PER_CLASS Proposal is a subclass of ExtendedEntity that has been stored in a single table so far. Now I want to...

LINQ BuildContainsExpression With OR conditions

Hi, I'm trying to get the following SQL query to work in LINQ: Select id from table1 where id in (1,2) or canceledId in (1,2) I'm using BuildContainsExpression to achieve the "IN" condition, but I can't figure out how to implement the "or" condition. My shot in the dark is as follows: var identifiers = new List<int> {1,2}; va...

Passing Object as a parameter to a WCF Service

I have a method AddEntity(object o). I am figuring out which entity type it is on the server side using reflection and such and adding it to the database. I am using Self Tracking entities. However this is the error I am getting. "Element contains data from a type that maps to the name . The deserializer has no knowledge of any type th...

Use SQL Information to Populate Schema Documentation and Code Comments Using Hibernate Tools?

I have set up Hibernate Tools from within Eclipse to autogenerate classes based on an existing DB. For each of the tables I have documented them and each of their columns within SQL Server. Is there a way to use that documentation information to comment the generated classes and to populate the schema entity documentation? I see that ...

I cannot find template ADO.NET Entity Data Model in VS2010

Greetings, In VS2010, I cannot find the template ADO.NET Entity Data Model from the Data section. I was doing: 1. create a silverlight(version 4th) project with a WebSite 2. right click the web project, Add -> New Item -> Data Section(actually, I tried every one) But i cannot find it!! It's weird! Then, 1. I tried to reset my VS templ...

Upcasting without retaining reference to derived type

I have a class called Resource, this is inherited by a class called ResourceMeta I need to upcast ResourceMeta to Resource without it still thinking it is a type of ResourceMeta. When I try to save my object using entity framework, it will complain about mappings not existing, rightly so because it will be trying to save ResourceMeta r...

Update non-scalar entities in Entity Framework v4

Currently I am updating the scalar properties of the candidate object like so: public Candidate EditCandidate(Candidate candidateToEdit) { _entities.Candidates.Attach(new Candidate { ID = candidateToEdit.ID }); _entities.Candidates.ApplyCurrentValues(candidateToEdit); //update candidate.contact h...

Visual Studio: How do you refresh metadata for Linq to Sql/Entity Framework

I have a view that I have been trying to map in either entity framework or linq to sql. However when querying the view it just crashes horribly (it is just this view). Because the error message is completly generic I thought I would just divide and conquer, and delete half the columns on my view (in sql server), and then update the Dat...

Entity Framework 4.0 // Attributes on Relationships

I've tried both "Model First" and "Generate Model from Database". I have a basic example outlined below (DDL shown). There is a M:N relationship between Employees and JobTitles. An Employee can have several JobTitles. This alone is trivial using the edmx visual designer. However, I want to put an attribute (scalar property) ~~on the r...

Entity Framework

Hi i have Entity Model with lets say 3 entity's like so all related of course: 1.-----Costumers------- CustomerId CustomerName 2.----CustomersOrders----- CustomerId OrderId Total 3.---Orders------ OrderId OrderName And I want to display orders of some costumer in GridView like so: ----------|---------- OrderName|Tota...

EF4 return new unique identifier from stored procedure

Hi, I am using EF4 and MVC 2. I am inserting a new record to the database, and I need it to return the new ID value. My stored procedure ends like this: SELECT SCOPE_IDENTITY() AS NewApplicationID; Here is my action method: public ActionResult CreateApplication(ApplicationViewModel applicationViewModel) { if (ModelState.IsValid...

Entity Framework Tools for VS 2008 RTM (.net 3.5 sp1)

I'm trying to add ADO.NET Entity Data Model in my project but i can't access/find it. I found this link text but it requires VS2008 Beta 3.5 version while mine is vs2008 RTM 3.5, is there a way i could install this? ...