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
1answer
45 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
2answers
43 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
39 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 ...
0
votes
0answers
20 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 ...
1
vote
1answer
63 views

Group By And Two Counts

I'd like to know if there's any better way to write this query: ...
4
votes
2answers
82 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: ...
5
votes
1answer
109 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
49 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 ...
4
votes
2answers
67 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 ...
3
votes
1answer
26 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). ...
2
votes
0answers
62 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 ...
4
votes
1answer
50 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
81 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 ...
1
vote
0answers
66 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
62 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 ...
2
votes
0answers
58 views

Domain modelling with Repository [closed]

I've been struggling with some architectural problems which I'm having a hard time figuring out myself. Im trying to construct a basic structure of a project with the domain model and repository ...
2
votes
0answers
36 views

Tracking sports statistics

I am designing a new application to track sports statistics. I am using code first migration. I have the bare minimum POCO setup. The problem is I am not happy with the design specifically how the ...
3
votes
1answer
86 views

Populate Drop Down List from SQL Database

I am populating a drop down list from my SQL database. List should be able to be displayed with active only, inactive only or both at the same time. OfficeRepository.cs: ...
1
vote
0answers
87 views

Entity Framework 6.0.2 - Performance of Auditable Change Tracking Part 2 of 2

This is Part 2 of a question about performance and general best practices. Part 1 is located here. The body of the messages are the same to illustrate their similarity, the difference is the code ...
3
votes
1answer
305 views

Entity Framework 6.0.2 - Performance of Auditable Change Tracking Part 1 of 2

This is Part 1 of a question about performance and general best practices. Part 2 is located here. The body of the messages are the same to illustrate their similarity, the difference is the code ...
5
votes
1answer
300 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, but it appears both Smeegs and Servy are quite a bit smarter than I am ...
8
votes
3answers
168 views

'Better' way to handle adding a record

Scenario: I am using a helper class called 'OutputHelper' to add a new record to the table 'Output'. My 'Output' object contains the following: ShiftID Model WorksOrder LotNo Quantity ShiftHour I ...
1
vote
0answers
444 views

Code First/Database First Entity Framework MVC [closed]

The following example is taken from the book Pro ASP.NET MVC 4 - Adam Freeman. This book does a good job going over the basics of the MVC framework. In it a ...
4
votes
1answer
222 views

Code First Entity Framework

Is the following good design for doing entity framework code first? What am I missing for a production system? I haven't included all my code, just a snapshot... My application, doesn't update the ...
1
vote
1answer
133 views

A genric extension method to filter Linq-EF queries

I have various types of EF entities, all of them have a navigation property called "Employee". When generating reports the user will have the option to filter the report according to the different ...
8
votes
2answers
181 views

Should a year and month be stored as separate fields or as a date?

We have a table with calculated data that groups sales by product, year and month, to provide fast querying for statistics. My colleague argues that the year and month should be two separate fields, ...
0
votes
0answers
88 views

Can this DbGeography calculation be done better?

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

Entity Framework, code-first repository pattern review. Where to validate?

I've been iterating on my repository pattern implementation over the course of the past 4-5 months. In my new projects I choose to use this pattern and I try to improve upon what I learned in previous ...
5
votes
1answer
160 views

Logging Entity Framework Changes - improve performance

I have the following code to log changes using Entity Framework 6. At the moment it only logs changes to a particular table - but I intend to expand it to cope with any table. I'm not sure of the ...
1
vote
1answer
80 views

Inserting using multiple contexts into LocalDB

I've written this ActionResult to model an Order that goes through. I couldn't think of another way to write this without using context ...
1
vote
1answer
93 views

Unit of work and common implementation

I have some questions regarding a common implementation of the UoW, Repository Pattern and EF: ...
3
votes
1answer
67 views

Retrieving statistics about URL clicks

I'm pretty new to ASP/MVC but have had some prior programming experience. I am trying to retrieve statistics about URL clicks - total clicks and unique clicks by IP address. I started with: ...
1
vote
1answer
60 views

EF adding Item with children

I'm working on my pet project with MVC 5 and EF, and everytime I'm adding a parent with it children (I have the children ID's) I have to go to the database, because if I just create a new child with ...
5
votes
2answers
4k views

Update only modified fields in Entity Framework

I'm working on a website on ASP.NET MVC4 and EF5. I want to ensure that only modified values are updated in the database. I'm using a unit of work pattern and repositories for data work. Here's the ...
2
votes
1answer
342 views

Is this correct usage of Repository + Unit of Work + Service Pattern

I have project where I need to use C# and Entity Framework. After my question here, I have decided to use Unit of Work and Repository patterns. This is the first time when I'm using this. Can ...
2
votes
1answer
318 views

Nested select Linq

Is there a simpler and optimized way to calculate listAdminCorePriveleges and privileges ? ...
1
vote
1answer
70 views

Metadata query performance optimization

SQL Server 2008 R2 + .NET 4.5: I have the following metadata table: ...
2
votes
1answer
320 views

Enabling discard pending changes on DbContext

This code review request is tightly coupled with this SO question, this is the solution I implemented to solve the problem being asked about there. All my ViewModels get constructor-injected with a ...
5
votes
1answer
3k 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 ...
2
votes
1answer
4k views

Unit of Work and Repository Design Pattern Implementation

User and Role are just examples; also, code is sparse on purpose (i.e. for demonstration purposes only). Thoughts? (e.g. good, ...
1
vote
1answer
131 views

Creating models manually in mvc

I am creating my models manually. I have five tables in my database as follows : 1. Members 2. MemberTypeMasters 3. Payments 4. Relationships 5. StatusMasters ...
0
votes
1answer
179 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 ...
1
vote
0answers
84 views

Review WCF client class

Please review, the class is responsible for wrapping requests to a WCF Data Service, which tidies up calling code. Transactions are implicitly supported. It should efficiently send just updates to the ...
2
votes
1answer
1k views

When to use separate DBContext classes?

I know that the DBContext represents a session (Unit-Of-Work and Repository) with the database, however I an unsure as to when I should have a different DBContext. Currently, I have a separate ...
5
votes
2answers
1k views

MVC Layered Project Structure

We are starting a new web project using C# / MVC 4 and Entity Framework 5 for data access. I've decided to go with an n-layered approach for the structure of the project and I would like some feedback ...
4
votes
1answer
519 views

DbSet<T> IncludeAll method

The Problem As an ASP.NET MVC4 developper, I'm using Entity Framework a lot. Considering performance I often use lazy loading for my models. ...
2
votes
3answers
80 views

Best Practice - Passing by Entity or EntityId in repositories?

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

Can this ordering logic be done better?

I am creating an ASP.NET MVC 4 app using Entity Framework and currently I am creating orderable tables. For that I have created the following logic to handle the different orders: ...
-1
votes
1answer
181 views

How does this GetType() work? [closed]

I thought .GetType() was a method that had to be used like myProperty.GetType(). But, as you can see, it is being used simply ...
3
votes
1answer
587 views

Review Repository and UnitOfWork implementation

I've done a LOT of reading about creating a Unit Of Work and Repository based implementation for my Entity Framework based application. I have come up with the following - what problems can you find? ...