The ADO.NET Entity Framework is a set of ORM (Object-Relational-Mapping) tools for the .NET Framework, since version 3.5 SP1.

learn more… | top users | synonyms

4
votes
0answers
55 views
+50

EF6-Lambda Expressions deep big-tree query

I am looking to improve the following query. We are using EF6 (CodeFirst) and C# Lambda Expressions, and Repository/Unit of Work patterns. Also, we needed to restrict the query in a way that we ...
6
votes
4answers
202 views

Basic Entity Framework Repository implementation

Here is simple repository pattern that I use to access data in my database. I would like some advice on how to improve this code. Commenting on my code quality is also welcome too! ...
-4
votes
0answers
13 views

Explaination and Implementation Required ASP.NET MVC Complex Views [on hold]

I am new to MVC framework. below are my questions. as I'm new to this framework, Please give a detail info how to achieve it. 1) Is it possible to retrieve all the data from these tables through ...
1
vote
1answer
26 views

Update multiple records with Entity Framwork

I am wondering what the best way to update multiple records with Entity Framework is. This is how I normally do it, and it does work: ...
2
votes
3answers
89 views

Pass by Entity or EntityId in repositories?

Which is the best practice in getting data from repository? passing just by object or by Id? ...
3
votes
1answer
45 views

Entity Framework - updating two different arrays of child associations

Exercises have Muscles and Tools. When someone adds or updates an ...
2
votes
4answers
323 views

Silent Try_catch in high load socket server or not?

I'm working on a socket application that will listen to incoming messages from about 400 devices. They all send a message at least once per minute. Now I have a working program and it has been running ...
1
vote
1answer
28 views

Refactor Oracle Entity Framework lambda query

I had a ugly problem and wrote an ugly query. Query creates a cache that is used to get person id when I have {full_name, id_code?, birth_date?}. By question mark I mean that it is perfectly valid ...
5
votes
2answers
205 views

Static Data Helper for an Oracle Backend

What I would like to do is have a method call like: ...
6
votes
1answer
1k views

A generic way to use LINQ to Entity with types and operations unknown until run time

A question was asked here about reflection and LINQ to entity. I'm trying to modify the code that was presented to fit my needs. Here's what I am trying to accomplish: I'm writing back-end support ...
1
vote
0answers
14 views

EF query for calculating monthly trends

My application has a fairly important query that is used in a lot of places. Unfortunately it takes about 14 seconds to run, so I'd like to find a way of possibly improving it. The application ...
4
votes
4answers
624 views

Instantiating if null

I often have static classes which uses the DataContext somehow, and they all make a new DataContext, but often I already have ...
6
votes
1answer
3k views

ListBox for a many-to-many relationship

I'm looking for a good and easy to use solution for creating MultiSelectLists in MVC for many-to-many relationships. I have this following example code and it works fine, but it just takes a lot of ...
2
votes
1answer
42 views

Making the objectContext.CommandTimeout configurable?

I am trying to make the CommandTimeout value more configurable. I'm wondering if this is best practice to do so? I add the following to my <appsettings> ...
3
votes
1answer
70 views

Method to save child objects

I'm using Entity Framework 6 with database first. See the image for the relevant database schema I have the following method to save a Set to the database: ...
6
votes
1answer
113 views

Refactoring a LINQ query that (sometimes) returns null

I have the following LINQ query that should return a result for each Request. I'd prefer to have the query translated to ...
0
votes
0answers
38 views

WebApi synchronize database (EF 6) access

I'm working on an ASP.Net MVC 5 /WebApi 2 project. I'm using EF 6 code first for my database access. I've a WebApi action method in which I've to update some data in my database based on the request. ...
5
votes
1answer
48 views

Work around for EF6 bug 1748 in the Entity Framework

Entity Framework 6 fails to handle the maintenance of LocalDB's global list of databases. That is noted here: Application fails when attached mdf and ldf files are deleted Here is my code to work ...
6
votes
1answer
5k views

Entity Framework using Repository Pattern, Unit of Work and Unity - viable approach?

Using a combination provided from this example and this implementation, I'm creating a solution that decouples the UnitOfWork class from the individual ...
4
votes
1answer
89 views

Saving a sales order - too many repositories?

I am wondering if I have overdone it with repositories in the following code, which is to save a sales order. I understand that the purpose of a repository is to decouple the domain layer from the ...
1
vote
1answer
79 views

Multi threading in ASP.Net to increase performance of processing data from entity framework using anonymous types

Intro I am trying to populate a Multi-column Combo-box with a large amount of records.Depending on the selection the user has taken there can be 1 - 50000 items in the Combo-box (I may not display ...
8
votes
1answer
628 views

Multiple repository calls or LINQ query

These two methods do the exact same thing (or at least they are supposed to!). They both pass a simple test based on a mock context. Neither has been exposed to any integrated testing yet. Would ...
4
votes
1answer
62 views

Insert Model object effectively using entity framwork

I have a WPF MVVM Application. I have a Customer Model which is generated by an entity framework (Database first approach) and one CustomerViewModel where I ...
2
votes
1answer
60 views

BaseRepository for EF6 - updated

Previous question: BaseRepository for EF6 I've update my code. Is it correct now? I've changed IEnumerable to IQueryable. ...
8
votes
6answers
336 views
3
votes
3answers
215 views

Entity Framework with multiple connections open?

I'm learning Entity Framework and I'm wondering if this code is the proper way of doing this. Basically this is my attempt at refactoring a very long controller in ASP.Net MVC 4. I'm using Entity ...
2
votes
1answer
80 views

Seperating Entity Framework into BLL

I have an Entity Framework working with a SQL database. A Web Forms application is currently communicating directly with the Entity Framework model from code behind. I have been tasked with creating a ...
1
vote
1answer
196 views

Serialize the properties of an entity framework entity to data fields and back

I am trying to write code to convert properties of an Entity Framework entity to strings and back. Here is the code so far that converts back from strings to the object properties. I am stuck trying ...
2
votes
2answers
72 views

Add chat to an MVC database: Can I condense this code and is it appropriately placed?

I have these relevant tables in an MVC website: Server ServerPlayer ServerPlayerChat Servers have serverPlayers, ServerPlayers have ServerPlayerChats. Simple enough and expectable. I'm using ...
5
votes
2answers
190 views

Getting list of daily team goals

The old code I had before was atrociously slow but after some advice and research I was able to take a 2-5 minutes run time down to about 5-30 seconds. That is acceptable, but still looking to have ...
2
votes
1answer
68 views

Compare Collection with the information in DB using EF and LINQ

I want to inform the Receivers about new contracts we have this week. After I sent the Emails, the Information about sent contracts are stored in MS SQL Database. To avoid that someone become the ...
4
votes
1answer
112 views

EntityFramework-based filtering

I am trying to use the following form to enter new info into a database. I am trying to use the entity framework. I have the following classes of Interest: ...
2
votes
1answer
97 views

Parent/child relationships: adding/updating details to an answer

Answer is the Parent table and AnswerDetail is the child. Below works, but I'm wondering if there is a better way to do this using EF? My Method Signature is this: ...
5
votes
3answers
153 views

Calculating total sales from each member

I am building a new system that is using some tables from an old system. For each user on this new system, I need to go to the old system and total up their sales. Currently it takes between 2-5 ...
3
votes
1answer
129 views

Implementing the Repository Pattern

I'm new to this pattern and I see arguments online about different implementations. I have the following code and it seems fine to me, but I'm wondering if having to pass the DBContext into the ...
5
votes
2answers
500 views

Unit of Work and Repository with Entity framework 6

Based on the reply of this question I have created the following code. I need to check whether it's good or not. Here is my entity class: ...
4
votes
1answer
89 views

Am I even using the Entity Frameowrk and/or LINQ the way it is supposed to be used?

I feel like just because the below works doesn't mean it is correct, I want to improve it but I can't really figure out how. Besides the fact it is down right ugly I feel the performance could be ...
4
votes
1answer
278 views

Database first entity framework, repository, service, UnitOfWork pattern

I have seperated my project into two projects. One is the web forms project and the other is the Model project with contains a generic repository implementation, a service class for each of my ...
1
vote
1answer
71 views

Group By And Two Counts

I'd like to know if there's any better way to write this query: ...
4
votes
2answers
87 views

Retrieve Tasks by Employee

I think I've done a decent job keeping this query simple and understandable, but I'd like to know if you have some more advice. My relevant entities are defined like this: ...
4
votes
1answer
171 views

Model Design for MVC4 Applications using Entity Framework Code First

I would like to put the following design to your consideration. This is the pattern I use to follow when I'm building a Model and Data Access Layer for an MVC Application (using Entity Framework 5). ...
6
votes
1answer
336 views

MVC 5 & EF 6 - Repository & Unit of Work Pattern

I have been looking through Code Review on the subject of Unit of Work and Repository patterns and realised that my implementation appears to provide very similar functionality but in reverse class ...
4
votes
1answer
106 views

Using static management class to control db transactions through an EF6

I have the class below to manage my specific implementation of a membership system using entity framework 6.1 Is the use of static access correct in this case? as far as I understood that EF context ...
5
votes
2answers
216 views

Entity Framework Skip and Take too slow

The following code achieves what I require, reading 10000 rows at a time: var query = repository.Subscribers.ToList().Skip(numberToSkip).Take(numberInBatch); Is ...
0
votes
0answers
127 views

Can this DbGeography calculation be done better?

Given the following piece of code, can it be done better: ...
4
votes
1answer
103 views

Verifying the Entity Data Model schema against a production database

We have an entity data model (database first) for a legacy product we are migrating to .Net from Delphi. We recently deployed to a server where some of the tables had been modified and columns ...
1
vote
1answer
90 views

Class to Return Single Integer

I have a class used to return a single integer, but think there is room for improvement. The class should only return a single row every time and if no row is found it might be a good idea to throw an ...
7
votes
1answer
655 views

Efficient way to deal with maintaining Many:Many relationships in EF Code-First

(I posed this in SO, but since it's a kind of code-review question, it's now here too) I've got this all working, but it seems to be quite long winded, and I thought I'd post here and see if I'm ...
1
vote
0answers
135 views

Generic Repository, UnitOfWork and IOC container

I am stuck to define a generic repository with AutoFac IOC container. I am keeping thing very simple and only showing relevent information. I have a BaseEntity ...
4
votes
1answer
64 views

Should I create two seperate Services and then combine them or have one large?

Basically, I have two separate tables, Campaign and CampaignDetails. They relate via CampaignID. I want a service that can handle both at the same time, as they're closely related and when one gets ...