entity-framework-4

Entity Framework 4.0 - Can I send a complex type to the client over WCF ?

Hey, can anybody confirm the following scenario will work: I am developing a 3-tier application in .NET 4.0: Winforms Client, aspx server and SQL 2008 database. The server communicates with the SQL 2008 database by means of Entity Framework 4.0, and returns the entities in forms of STE's (in a separate assembly) to the client applicati...

EF4 - Is there any way it can be made to support unique indexes

My primary key is a guid column and I would like to have a unique index on another column in the table. I read that EF4 doesn't do anything for unique indexes. My question is: Can I add to a partial class any code that would allow me to check for non-unique values before my data hits the database. Currently I'm using the following config...

Unable to add foreign keys manually in Entity Framework 4

So I have a sql server 2008 database with 9 tables in them, they don't have any set relationships but is still used as if they have it, this however makes it so that I cant import the relationships when importing the models from the database. Now, when trying to add an association between two tables work but when I want to point tb1.Id ...

Difference between POCO and Self Tracking Entities

I have POCO's in a separate project and now I need Self Tracking Entities. Does anyone know if I need to generate new POCO's that are self tracking and they will replace my current POCO's? Or, do I setup self tracking entities in addition to my current POCO's? Thanks! ...

Warnings in edmx file when upgrading from 3.5 to 4

Hello I updated my solution from .NET 3.5 to 4.0, and thanks god, I just had to fix minor things. But what I don't understand is, the edmx file generated many warnings like this: Error 2005: Mapping Association 'FK_CP_C' is redundant: Its referential integrity constraint provides sufficient information. You can safely delete the mappin...

The property 'Id' is part of the object's key information and cannot be modified

Hi all, i'm using Entity Framework 4.0 and having a silly problem that i can't figure out. I have two tables: Contact: Id (primary key), Value, ContactTypeId (foreign key to ContactType) ContactType: Id (Primary key), Type (Home, Cell, Work, etc.) Entity Framework created the following two entities: Contact: Id, Value, ContactType...

ASP.NET Dynamic Data 4.0 - Search Results?

I have a ASP.NET (VB) Dynamic Data Project in ASP.NET 4.0. It works great - and offers filtering - but now I want to add searching to it. What is the best way to accomplish this in ASP.NET 4.0? Is there any built-in functionality for performing searches declaratively? ...

Entity Framework 4 column conversions - SQL Server - SQLite

I have a SQL Server database and Entity Framework Model setup with POCO objects, this is working fine. However, I have also created a Sqlite database from the SQL Server database (using a simple conversion process). So I have created another EDMX file for the SQLite database, which I would like to use my existing POCOs generated from t...

Entity Framework 4 Stored Procedure Returns None

If I create a function import for a stored procedure in Entity Framework 4 and set "Returns a collection of" to None I don't get the stored procedure as a method on the Data Context. How do I run this stored procedure? I am using Entity Framework 4 with Self Tracking Entities. All the other return types seem to work ok for me as far as ...

EF4 Update Entity Without First Getting Entity

How can I update an entity without having to make a call to select it. If I supply the key for the entity, should it not know to update after SaveChanges() is called on the ObjectContext. I currently do this: var user = context.Users.Single(u => u.Id == 2); user.Username = "user.name"; user.Name = "ABC 123"; context.SaveChanges(); Th...

ASP.net MVC 2 Application Tutorial using Entity Framework with many Tables

I am a newbie to ASP.net & MVC 2, and have understood the basic concepts of how views, routes and controllers are implemented in it. Having great trouble with the MVC 2 "Models" though because I have always avoided ORM's. Please point me to some good ASP.net MVC web application tutorials that use ADO.net Entity Framework with many table...

How can Entity Framework queries be reused (using methods)?

I'm trying to reuse part of a query, because it's complex enough that I want to try to avoid code duplication. It seems that when calling any method inside a query, you end up with: LINQ to Entities does not recognize the method {X} method, and this method cannot be translated into a store expression What I would like to do...

Entity Framework v4 Code-Only Connection String

I have recently begun to use the EF v4 Code Only library for some projects I am working on. However, I have run into a bit of a snag. I can't seem to figure out the proper format for the connection string. I have used the following code to build the connection string: string connectionString = new EntityConnectionStringBuilder { Pro...

Entity Framework - Saving child entities on update

Hey, I have an Invoice entity and it has child InvoiceLog entities. When I first create an Invoice and add its InvoiceLog entities and save, it works fine. However, if I then edit the Invoice and try to add additional InvoiceLog entities, it completely ignores the new InvoiceLog entities and doesn't save them at all. Any ideas what I'm ...

Rollback in Entity Framework 4.0

Hi gurus, i have a Customer class which includes a Contact class that stores all the contacts for that particular customer, so they are linked with a foreign key relationship. Here is my scenario: the user Edits the customer's info including the contacts, and then decides to hit the "Cancel" button. The contacts are bound to a grid so ...

Lazy loading, Deferred Loading and Eager Loading in Entity framework

What are the differences between these 3 types of loading? Can someone explain with an example? Different resources online use different definitions causing more confusion than necessary. ...

Advantages of Code Only model in Entity Framework 4?

The Entity Framework 4.0 Futures preview (CTP3 now) has a code only modeling paradigm for mapping between your types and the database. No edmx files involved and no EDM designer needed. I wanted to know what are the big advantages of Code Only vs Model First? What can be done in Code First which can't be done in other models (Model Firs...

ADO.NET Ef4- How can i map a entity to stored procedure without mapping to table.

We are using ado.net entity framework 4.0 for our database layer and I am a newbie to ado.net entity framework. I have created entity via adding a entity in entity framework. I want to map that entity with stored procedure only not table of the database. Stored procedure will return same column as entity. How it is possible and how i can...

What is the best implementation for changing the database schema at runtime using Entity Framework 4?

We are building an ASP.Net MVC 2 multi-tenant application on SQL Server using the "single database, separate schema" model discussed, among other places, here and here, where each tenant has one or more users and is split out with its own, tenant specific, SQL Server schema. The application is using Entity Framework 4. In order for u...

EF4 how to delete entity in many-to-many relationship using POCOs

Hi, I'm using POCOs in combination with EF4 and some entities are in many-to-many relationships, in my case objects of class User and objects of class PrivilegeGroup. This is how class User looks like: public class User { public int UserID { set; get; } public string UserName { get; set; } public string UserPassword { get...