entity-framework

How does one calculate CPU utilization programmatically ?

Hi, I have a benchmarking program that calculates the time (in milliseconds and ticks), for a persistance to Entity Framework 4.0. Is there a way to calculate CPU load ? I am guessing that I would need to query Windows to find out my CPU frequency, how many cores, etc. Does this sound right ? If so, what part of the .NET framework r...

EF4 0..1 relationship leads to Error 2016: Condition cannot be specified

This is very similar to a previous question (and may be the exact same question) but I really didn't understand the answers enough to be able to tell for sure. I am using Entity Framework 4 in Visual Studio RC1 to create an azure service app (so it is .Net 3.5). I have a database with a lot of patterns like the following: Thing ...

MVC and repository pattern data efficiency

My project is structured as follows: DAL public IQueryable<Post> GetPosts() { var posts = from p in context.Post select p; return posts; } Service public IList<Post> GetPosts() { var posts = repository.GetPosts().ToList(); return posts; } //Returns a list of the latest feeds, restricted by the coun...

ADO.NET Known Issues?

So, I'm starting a new Project in my company, and it's kinda big. We are going to use .NET 3.5, and I wish to known if there are any know bugs or perfomance issues that could give weird behaviour for my project? I'm reading some things about EFv4 and all they say is that EFv3.5 have too many problems. After all, what's the best and fast...

Entity Framework in n-layered application - Lazy loading vs. Eager loading patterns

Hi all. This questions doesn't let me sleep as it's since one year I'm trying to find a solution but... still nothing happened in my mind. Probably you can help me, because I think this is a very common issue. I've a n-layered application: presentation layer, business logic layer, model layer. Suppose for simplicity that my application ...

Concurrency checking in Entity Framework with stored procedures while deleting

Hi, My UPDATE and DELETE logic are in stored procedures. I've built an entity framework model with mappings to these procedures. In spUpdate I return the new timestamp column so the EF could detect concurrency conflicts. It works fine. I have a problem with the spDelete because I don't see mappings for return values in the "delete fun...

Best way to return result from business layer to presentation layer when using LINQ-to-Entities

I have a business layer that has DTOs that are used in the presentation layer. This application uses entity framework. Here is an example of a class called RoleDTO: public class RoleDTO { public Guid RoleId { get; set; } public string RoleName { get; set; } public string RoleDescription { get; set; } public int? Organiz...

Deleting entity with child relationships using .Net Entity Framework problem

My God, EF is so frustrating. I can't seem to be able to get my head around what I need to do so I can delete an object. I seem to be able to remove the object but not the related child objects. Can anyone tell me what is the rule of thumb when you want to delete all related child objects of a given object? I've tried loading all relat...

Unique keys in Entity Framework 4

An existing DB schema has unique, non-primary, keys, and some foreign keys that rely on them. Is it possible to define unique keys, which are not primary keys, in Entity Framework v4? How? ...

Entity Framework with ASP.NET MVC. Updating entity problem

Hi people. I'm trying to update an entity and its related entities as well. For instance, I have a class Car with a property Category and I want to change its Category. So, I have the following methods in the Controller: public ActionResult Edit(int id) { var categories = context.Categories.ToList(); ViewData["catego...

Why can't I see the 'dataset project' property in Visual Studio DataSet designer?

Hi, I am trying to follow 'n tier app design' tutorials and they tell me to set the DataSet Project property from the Data Set Designer in VS, to split table adaptors and entities into seprate projects. I can't see that property! (I'm looking in the same place shown on the videos... all other properties match) Does anybody know why? ...

Need to get to the foreign keys of an entity marked as "Deleted" for auditing

I'm using v1 of EF(.NET 3.5 SP1). I'm subscribing to the SavingChanges event of the ObjectContext wherein I audit deletes for a particular entity type. I need to get to the foreign keys of the entity being deleted i.e EntityKeys of the related entities (RelatedEnds) but the EntityKeys of the related entities are nulls. Is there any way ...

Add child to existing parent record in entity framework.

My relationship between the parent and child is that they are connected by an edge. It is similiar to a directed graph structure. DAL: public void SaveResource(Resource resource) { context.AddToResources(resource); //Should also add children. context.SaveChanges(); } public Resource GetResource(int reso...

Entity Framework: Refresh does not fire property notification?..

I have a class Item. My window shows a TreeView with those items and there is a details form on the right (to edit the name of the Item). Anyway, when I edit the item name in the TextBox and then press Cancel button (which calls Context.Refresh(StoreWins, myItemEntity)) the UI does not get updated with old values from the database right...

How to store the Connenction String in only the Data Access Layer (.NET Class Library)

Hi! I got a solution that includes 3 different projects, a Class Library, a Web Service and a Windows Service. MySolution.DataAccessLayer (Class Library) Using Entity-Framework 3.5 to access the database. MySolution.WebService (Web Service) MySolution.WindowsService (Windows Service) My problem is that a have to include the Connect...

How to perform a many-to-many Linq query with Include in the EF.

Hi, I don't know how to perform this query using Linq and the EF. Imagine I have three tables A, B and C. A and B have a many-to-many relationship. B and C have a 1-to-many relationship. I want to obtain records from B including C but filtering from A's Id. I can get easily the records from B: var result = Context.A.Where(x => x.Id.E...

Update one-to-many EntityKey using Foreign Key

To use by the easiest way Entity Framework, I use partial class to add Foreign Key on most important Entities Model. For example, I have an Entity "CONTACT" which have "TITLE", "FUNCTION" and others. When I update a CONTACT, with this code, Foreign Key are automatically updated : public int? TitId { get { if (this.TITLE...

EF and design pattern

Hello, I’m working on a high volume transactional enterprise application(asp.net, windows app, oracle app as client) which has been designed using n-tire application and SOA architecture .The application was developed in the .NET platform utilizing C#,VB.NET, Framework 3.5 (I’m planning to upgrade to the , Framework 4.0), EF( EF in the ...

Entity Framework - Insert with foreign key

Hi, Apologies if there is clear answer for this somewhere. But I can't insert into a simple table due to it containing a foreign key. Task Table TaskId (PK) Description StatusId (FK) Into which I try to insert like so: Task t = new Task(); t.Id = 1234; t.Title = "foo"; t.Status = db.Status.ToList().F...

Why should I use Entity Framework over Linq2SQL ...

To be clear, I am not asking for a side by side comparision which has already been asked Ad Nauseum here on SO. I am also Not asking if Linq2Sql is dead as I don't care. What I am asking is this.... I am building internal apps only for a non-profit organization. I am the only developer on staff. We ALWAYS use SQL Server as our Datab...