Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [entity-framework]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
139 views

EF save method that has three conditions

I created this save method that has two conditions. One condition is checking if coordinatorsId is not 0 and another one is ...
1 vote
1 answer
271 views

Concurrent Requests Handling in ASP.NET Web API 2

I was having concurrency issues with my ASP.NET Web API 2 project with .NET Framework 4.6.2. (EF 6), although it has been live on production that has been running for more than 1 year, this problem ...
0 votes
1 answer
2k views

Making a generic web API controller when using multiple tables with similar fields

I have been trying to refactor my code since I found I've been doing a lot of copying and pasting to implement the logic of the web API controllers. Here's how the controllers looked like before ...
1 vote
1 answer
20k views

Passing model to _layout.cshtml

I have login page that looks like: It has a ViewModelBase and a ViewModel as: ...
7 votes
3 answers
26k views

Joining to in memory List

I have an in memory list that I am joining to results from a query using entity framework. My list will most likely never be greater than 2500 records. The results from the database can fluctuate, ...
1 vote
2 answers
133 views

EF 6.0.0.0 include linked table delete with reordering of data

I have this ef 6 delete method where I build <List> the related entities that will need to be deleted. Then I use ...
2 votes
4 answers
878 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 ...
6 votes
3 answers
6k views

Ordering data by boolean

I have a bit of EF Lambda code which returns a list of data from the db table, then orders by a field called IsDefault At first, the code was ...
4 votes
2 answers
527 views

Trying to clearly seperate my logic in my program

My problem is I need to know is my code in my CRUD functions structured well and effectively? I plan to implement CRUD for Locations entity too. hopefully without redundant code. you see how one ...
1 vote
1 answer
8k views

How to optimize for loop with nested foreach

I want to optimize this code of generate pdf file with many nested loops, what makes it slow that i have for loop with 20 items ...
0 votes
1 answer
159 views

Entity Framework - component shop using polymorphism and generic repository

I am creating a .NET Framework MVC EF application for PC components. I wanted to make full use of inheritance, polymorphism and generic repository pattern - but was wondering if my initial design ...
1 vote
2 answers
97 views

Efficiency of finding one database record using two ID's

I'm using C#, .NET Core and the entity framework and am currently working on optimizing various functions for better performance. One of the main functions is getting a calculation based on two ...
1 vote
1 answer
87 views

Copy vehicle information from JSON list to relational database

I am looking for suggestion to make my for loop iterate faster. With about 2000 rows of data. Below code is taking lot of time to run. So far I have followed various Stack Overflow answers. For ...
5 votes
1 answer
355 views

Displaying information about an order when selection changes

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 ...
9 votes
4 answers
24k views

Threadsafe DBContext in singleton

I found out the hardway that access to DbContext in .NET is not threadsafe. I have a singleton for logging things using a dbcontext. The original version uses something like ...
2 votes
1 answer
1k views

Parsing large text files into database

I'm a new self taught "programmer" that has been given the task at my job to parse through generated .txt test records and insert the data into a database. Usually when given a task like ...
4 votes
0 answers
141 views

Repository pattern method implementation with entity framework and C#

I have two entities in my database: Employee and Shift. I want to implement a C# repository pattern method, that given two ...
1 vote
0 answers
624 views

Adding multiple child entities to a parent entity when creating the parent entity

I have a form on a page to add a Post (parent), before submitting the form, a user should be able to add 1 or more Sections (children) to the Post. The form: ...
2 votes
1 answer
110 views

View model using different datetime component

Any advice on how to make this code; cleaner, more effective, just overall better! Program setup object that is coming from the database EF. It then maps the object to a view model and converts ...
2 votes
1 answer
1k views

Entity Framework Core DbFunction for square root

I'm porting my site over from .NET Framework / MVC 5 / EF6 to .NET Core 3.1 MVC / EF Core. MSSQL Server for the database. EF6 has SqlFunctions of which one method ...
4 votes
2 answers
714 views

pagination in entity framework and refactoring

I have an api end point which returns the paginated result, the corresponding code for that is as below: ...
1 vote
1 answer
111 views

Many to Many Relationship using EF Core

I've implemented Many-To-Many relationship and wonder if this is the optimal way for it. Since I do not have extensive EF Core experience I would love if someone with more experience could check it ...
1 vote
0 answers
77 views

Entity Framework optimization when using transactions

I want to save NUnit local tests in a mysql database hosted in Amazon RDS, and I'm wrapping up everything in a transaction like so : ...
2 votes
0 answers
54 views

Sharing model for different ORM's

I am building a MySQL to Realmdb converter app. I use Entity Framework to deal with MySQL, so below is the code of one of my model classes. I don't want to have multiple classes representing the same ...
2 votes
0 answers
36 views

Web API wrapper design and sharing EF database context

I'm trying to keep my sanity while working with a legacy winforms application that uses an web api, both maintained by my team. In the past we have multiple cases of methods using wrong api endpoints,...
11 votes
3 answers
17k 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. ...
12 votes
2 answers
7k views

Query Builder pattern with use of FluentApi

Recently, I've come up with an idea of building a custom query builder combine with FluentApi. Expected usage: ...
1 vote
0 answers
70 views

Concurrent requests are not permitted in specific time period

In my web API, the client wants me to implement logic in order to control/block concurrent requests in a specific time period. I added RequestInterval which is 10 seconds in the appsettings of web ...
9 votes
3 answers
911 views

Creating a round robin MySQL connection manager

Background I am working on an e-commerce website, my web server is written in ASP.NET MVC (C#, EF6) and I am using 3 instances of MySQL DB. These DBs are in a cluster (Galera Cluster) and they are ...
4 votes
1 answer
2k views

C# Windows Forms App: Adding An Element To The BindingSource And Save These Changes To The DB [closed]

I have build a C# Windows Forms app that used Entity Framework(DB first model). For the data I am using a .mdf database file. The data view of dbo.students: GUI: The Form1 class: ...
1 vote
1 answer
1k views

ASP.NET EF seed one to many relation

I am creating a simple model relation in ASP.Net core. My model relations are like this: A user can have many posts A post can have many comments A user can have many comments Now I am trying to ...
0 votes
2 answers
93 views

Multiple conditions for same table in EF

I am getting products using given parameters (name of real entity and columns changed for illustration purposes), ...
1 vote
1 answer
82 views

Exposing includes to client over webservice for database queries

I am using a CQRS type patter for querying data in my application. I am currently using entity framework to connect to the database. ...
1 vote
1 answer
292 views

Entity Framework invoice queries

I have these queries written in Entity Framework where I try to get: Name of the customer Most Recent Invoice Ref Most Recent Invoice Amount (£) Number of outstanding invoices (#) Total of all ...
4 votes
1 answer
971 views

Initializing entity framework context in constructor

We use the architecture shown in the code below to initialize the DB context for our MVC 5 project using entity framework 6 We have the following questions related to it: Is it safe to initialize ...
1 vote
1 answer
69 views

Using nullable properties in a base class for record selection in Table per Hierarchy

I want to be able to list every Transaction associated with a Client in date order. ...
13 votes
4 answers
26k views

Storing Enum values as Strings in DB

I have a Data First Migration and have been struggling a little with storing an enum value as a string. (Im aware that enums should be stored as ints but, personally I have never liked this, yes ...
1 vote
1 answer
111 views

Calculate sum of an attribute across multiple repositories

I have multiple repositories that contain userId, paidDate and amount attributes like ...
1 vote
1 answer
188 views

ASP.NET MVC 5, EF 6 filter performance

I'm creating a filter with Linq in an ASP.NET MVC application. I was hoping I could get some tips on performance enhancements, aside from any possible performance enhancements. I have a few questions:...
5 votes
1 answer
8k views

Generic repository and generic service

I use the Repository/Service design pattern in my projects. I have doubts whether it is worth using common services BaseEntity: ...
1 vote
1 answer
1k views

UnitOfWork without repository and transaction

I've created the unitofwork class below: ...
5 votes
3 answers
161 views

Collect reporting data for each possible combination of filter properties

Basically I'm looking for a way to improve my code, and avoid making a lot of if statements and parameter combination manually, 'cause I need to return a query result depending in the parameters that ...
1 vote
0 answers
37 views

Console app to get XML from API and save to database

I am making a small console app to get XML from an API and then save the data to a database. While this project was not created via test-driven-development, I have tried to make it such that tests can ...
3 votes
1 answer
125 views

Small application for manipulating users and their activities

I made a small application using C#, SQL Database, entity framework , and windows forms to manipulate users (...
6 votes
1 answer
1k views

IQueryable Extensions working on expression for collection property

Followup to Repository searching code duplication My goal currently is to make the current implementation of my repository's IQueryable filtering less duplicative. First, I looked into passing ...
2 votes
2 answers
52 views

LINQ queries to generate a report on accrued work time on projects

The following code fetches data from a MySql database to generate a simple report on accrued work time on projects. I've been away from Entity Framework for a while and looking at this code you can ...
1 vote
1 answer
171 views

Authorization using Entity Framework in ASP.NET MVC

1. Backstory I recently starting programming and I found out that Entity Framework works perfect for my small-sized applications due its simplicity. I've made my custom authorize attribute for MVC ...
2 votes
1 answer
628 views

Generic UnitOfWork

I am trying to create a Repository & UnitOfWork for Data Access Layer. In my current implementation I have to modify my UnitOfWork everytime I create a new repository. I would like to avoid that ...
11 votes
1 answer
2k views

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

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 doing it wrong... I have a M:M relationship between an Installer and a MasterInstance. The ...
3 votes
2 answers
2k views

Optimize OrderBy Generic Method

Here is my OrderBy method which includes concatenated column names. Can this be achieved more efficiently? ...

1
2 3 4 5
8