entity-framework-4

Error reached after genereated entity framework classes by edmgen tool

Hello, First I read this question, but this knowledge did not help to solve my problems. In initial I've created edmx file by Visual Studio. Generated files with names: uqsModel.Designer.cs uqsModel.edmx This files are located on App_Code folder. And my web app work normally. In Web Config generated connectionstring automatically...

How to update a single field using EF4

I want to update a single field in my table for a particular row. I am using Entity Framework 4 and Visual Studio 2010. Options I can think of are: Using a Stored Procedure Direct connection to the database and using sql statement I am not aware of any more efficient method to perform this task. [EDIT] I would like to do the updat...

EF 4.0 Batch Inserts Vs Single Insert Exception

I have been encountering an issue with inserts in EF 4.0. During a migration from one system to another I migrate the values of three configuration tables into a database fronted by EF. The following code crashes: foreach (MyModel model in models) { if(entities.my_Model.Where(p => p.Id == model.modelId).Count() == 0 ) { ...

poco class custom name

Is there a way to a coded class called "Pessoa" decorate some atttribute to be referenced with a conceptual class named as "Person" that is in a conceptual model ? I'm mean: [Table("Person")] // or something like that public class Pessoa I tried [EdmEntityTypeAttribute(Name = "Person")] but no success.... ...

Using Entity Framework 4.0 in a .Net 3.5 Application

Is it possible to use Entity Framework v4.0 in a .Net 3.5 application? I mean, can i just reference the related assemblies for EF 4.0 and use it in my .Net 3.5 application? thanks... ...

Time for creation of database on site

Hi. When and where would you create database to develop web site using ASP.NET MVC 2 and Entity Framework 4 (CreateDatabase method). I think about first run of web site and redirect on welcome page, when controller creates database from model. But I doubt about details: 1. Where? In HttpModule, but request of any image or css will check ...

Are there any good resources for developing Entity Framework 4 code-first?

I am trying to convert my model-first project to code-first, as I can see dealing with the models with the graphical designer will become hard. Unfortunately, with all my googling I can't find one good reference that describes how to do code-first development. Most resources are out of date (so out of date they refer to it as code-only...

Entity Framework 4 with SQL Server Express files.

Hi all, I know that if you use EF in a model-first manner in VS2010 with a standard SQL Server database then it is easy to apply the generated DDL to the database. Is there an easy way to do this with .mdf files (SQL Server Express Files) Thanks in advance. ...

DAL Layer : EF 4.0 or Normal Data access layer with Stored Procedure

Hello Experts, Application : I am working on one mid-large size application which will be used as a product, we need to decide on our DAL layer. Application UI is in Silverlight and DAL layer is going to be behind service layer. We are also moving ahead with domain model, so our DB tables and domain classes are not having same structur...

EF4 code only - How do I change column order?

I setup the builder and used CreateDatabase to generate the database. However the table columns created are ordered alphabetically. Is there a way to control the order? ...

Can I mock Objectresult<T> of Entity Framework Using MOQ

I am using Entity Frameowrk 4.0 and I am calling a stored procedure which returns an ObjectResult and I tried to use MOQ and have not been able to mock ObjectResult. Has anybody been able to mock ObjectResult using moq? TIA Yaz ...

Using entity framework to detect changes in related table and action appropriate inserts and deletes.

Lets say i have a Person table, a Role table with a trel table PersonRoles linking them as many to many. I create a new person and assign them to 2 roles (role 1, role 3). I then want to edit this person; so i retrieve their data and bind their roles to a checkboxes. I change the values (Deselect role 1 and select role 2 instead) I the...

Entity Framework EDMX Model & Stored Procs

I am an Entity Framework newbie and am wondering if I am able to use it in the way I would like to. I am using Visual Studio 2010 and .NET 4. I have a Content Management system which stores all the data in an xml field of a table. The table - cmsContent - contains only two fields, id and XmlNode I want to create stored procs that query...

EF4 POCO WCF Serialization problems (no lazy loading, proxy/no proxy, circular references, etc)

OK, I want to make sure I cover my situation and everything I've tried thoroughly. I'm pretty sure what I need/want can be done, but I haven't quite found the perfect combination for success. I'm utilizing Entity Framework 4 RTM and its POCO support. I'm looking to query for an entity (Config) that contains a many-to-many relationship...

Too Many Left Outer Joins in Entity Framework 4?

I have a product entity, which has 0 or 1 "BestSeller" entities. For some reason when I say: db.Products.OrderBy(p => p.BestSeller.rating).ToList(); the SQL I get has an "extra" outer join (below). And if I add on a second 0 or 1 relation ship, and order by both, then I get 4 outer joins. It seems like each such entity is producing ...

"Dealing with uncertainty" - Entity Framework CodeOnly

This is a bit of a strange one but I've just seen something on twitter which kind of baffled me and I'm interested to know more. Rob Conery tweeted the following a couple of hours ago: Class name of the day: "Maybe<T>". Method of the day: "ToMaybe<T>()". He then went on to offer a Tekpub coupon to anyone who could guess where it came f...

Is there a way to get the "FromProperty" of the System.Data.Metadata.Edm.NavigationProperty?

On EF4: e.g: I have a SystemRole entityType that has a SystemUsers navigation property, and SystemUser entityType has a SystemRoles navigation property, the association is from SystemRole.SystemRoleId to SystemUser.SystemUserId. My question is: Is there a way to get the "SystemRole.SystemRoleId" & "SystemUser.SystemUserId" from the sp...

Entity Framework 4: Cannot map multiple many-to-many relationships to the same storage 'join' tables

Hi I have a table that uses TPH to provide multiple entity types. I also have a join table with two columns, both as foreign keys to the other table. I am using this join table for many-to-many relationships on one of my entities and it works OK. However, if I use it for another many-to-many relationship in another entity (an entity t...

Unable to specify abstract classes in TPH hierarchy in Entity Framework 4

Hi I have a TPH heirachy along the lines of: A->B->C->D A->B->C->E A->F->G->H A->F->G->I I have A as Abstract, and all the other classes are concrete with a single discriminator column. This works fine, but I want C and G to be abstract also. If I do that, and remove their discriminators from the mapping, I get error 3034 'Two ent...

Entity Framework 4.0 GetChanges() equivalent

Hi In LINQ to SQL, you can override SubmitChanges and use the method this.GetChangeSet() to get all the inserts, updates and deletes so that you can make last minute changes before it is committed to the database. Can this be done in EF 4.0? I see there is a override for SaveChanges but I need to know the equivalent for GetChangeSet()...