As of May 31, 2023, we have updated our Code of Conduct.

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
1 vote
2 answers
80 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 ...
Jefferson's user avatar
  • 445
1 vote
1 answer
5k 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 ...
Coder95's user avatar
  • 143
0 votes
1 answer
101 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 ...
Shaun Falconer's user avatar
1 vote
2 answers
95 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 ...
RDAxRoadkill's user avatar
1 vote
1 answer
86 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 ...
Jaskaran Singh's user avatar
-1 votes
1 answer
1k 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 ...
Youssef Ashraf's user avatar
2 votes
1 answer
657 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 ...
Ogg Vorbis's user avatar
4 votes
0 answers
138 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 ...
Jens Jensen's user avatar
1 vote
0 answers
320 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: ...
MF1010's user avatar
  • 107
2 votes
1 answer
80 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 ...
Jefferson's user avatar
  • 445
2 votes
1 answer
922 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 ...
suraj's user avatar
  • 33
4 votes
2 answers
311 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: ...
testcr's user avatar
  • 41
1 vote
1 answer
73 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 ...
sed's user avatar
  • 175
1 vote
0 answers
70 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 : ...
mark02's user avatar
  • 11
2 votes
0 answers
51 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 ...
Movsar Bekaev's user avatar
2 votes
0 answers
34 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,...
Rubens Farias's user avatar
1 vote
0 answers
49 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 ...
Fake Developer's user avatar
4 votes
1 answer
1k 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: ...
user avatar
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 ...
Bikram's user avatar
  • 113
0 votes
2 answers
86 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), ...
Mathematics's user avatar
9 votes
3 answers
760 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 ...
Hooman Bahreini's user avatar
1 vote
1 answer
222 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 ...
Tania Marinova's user avatar
1 vote
1 answer
66 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. ...
Martin Hansen Lennox's user avatar
1 vote
1 answer
83 views

Calculate sum of an attribute across multiple repositories

I have multiple repositories that contain userId, paidDate and amount attributes like ...
abdllhcay's user avatar
1 vote
1 answer
136 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:...
Train's user avatar
  • 301
5 votes
3 answers
159 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 ...
Manuel Gonçalves's user avatar
1 vote
0 answers
31 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 ...
Michael Brandon Morris's user avatar
3 votes
1 answer
124 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 (...
Aris Koutsoukis's user avatar
4 votes
1 answer
704 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 ...
prinkpan's user avatar
  • 191
2 votes
2 answers
46 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 ...
w4n's user avatar
  • 21
1 vote
1 answer
146 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 ...
Roberto99's user avatar
2 votes
1 answer
567 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 ...
niklodeon's user avatar
  • 193
-1 votes
1 answer
117 views

Handling Entity Framework in connected mode within Windows Forms [closed]

I know the difference between the Entity Framework connected mode vs disconnected mode. In connected mode we do all the stuff inside one single DbContext instance. ...
Ahmed Suror's user avatar
1 vote
2 answers
4k views

Using IQueryable.GroupBy to count related database entities

Given a DbSet<Client> from an Entity Framework 6 DbContext, I need to count the number of related ...
Sinjai's user avatar
  • 227
2 votes
1 answer
75 views

Repository to update flights

I have the Repository below, but I have noticed that there is a recurrent pattern try / catch which does not seem to be that ...
Natalie Perret's user avatar
2 votes
0 answers
3k views

Using Entity Framework to Call an Oracle Stored Procedure with Multiple Cursors

I wrote the following code to use Entity Framework 6 and Managed Oracle Providers to call an Oracle stored procedure that returns multiple cursors. Would like some input about the code I used to ...
ADH's user avatar
  • 336
1 vote
0 answers
2k views

Transaction integrity in asp.net core with entity framework and generic repository

I am not very experienced in Entity Framework, I previously used ADO.Net and Dapper for data persistence. For now, I only read Microsoft docs and watched a few video tutorials. I tried to stick to ...
ibubi's user avatar
  • 131
3 votes
1 answer
59 views

Registering an event participant, using Entity Framework and several associated models

I have a method that is responsible for receiving an object and perform the information saved with Entity Framwork, using the Repository pattern. The issue is that this object is, basically, a DTO. ...
Adolfo F. Ibarra Landeo's user avatar
3 votes
1 answer
2k views

Dynamic AuthorizeAttribute with database

I want to create a AuthorizeAttribute that gets the current ActionMethod RouteData and ...
AminM's user avatar
  • 93
2 votes
0 answers
137 views

How to optimize code to only pull separate table rows that are necessary

I have a Company Class, and separate normalized Address Class. I did this because the Address table will hold more than just Company Addresses, so I don't want "CompanyAddress", "EmployeeAddress", "...
Aaron's user avatar
  • 137
2 votes
1 answer
4k views

Adding or updating Company entity

Here I am trying to post a company view-model and update and insert according. But I feel I am writing it in wrong way or maybe there's a better approach. Here's my code ...
Siraj M's user avatar
  • 115
0 votes
1 answer
492 views

Filtering DbContext data dynamically by user input in WPF applications

I need to filter database data based on filters available to the end user in the form of search term text box, select boxes etc. I have put together this code and need feedback if this is a good way ...
W.M.'s user avatar
  • 103
2 votes
0 answers
44 views

Correct Way to Retrieve Header Records With Filtered Detail Records [closed]

I wrote this in LinqPad. It works. The whole point was to retrieve header records, and only include some detail records. I'm looking for possible improvements to this, specifically around the ...
Bob Horn's user avatar
  • 203
-3 votes
1 answer
129 views

Implement Entity framework insert with better performance [closed]

I have very slow performances on EF. I have many foreach, mappings. Do you have suggestion? I would like to make improvement without complicated refactoring and I would like to use EF. ...
Raskolnikov's user avatar
-1 votes
2 answers
91 views

Improving predominance for updating 40000 records using entity framework [closed]

I have Two tables Circuit and Tag, Circuit ------------------ Id Name Path Tag ----------- Id Name Circuit_Id Now I have to loop through all the tags and ...
Simsons's user avatar
  • 723
1 vote
1 answer
1k views

ASP.NET Identity 2.0 UserManager alongside with UnitOfWork and Service-Locator anti-pattern

I was wondering whether it is a good aproach to have Identity 2.0 UserManager next to UnitOfWork pattern? I am using ...
Marek's user avatar
  • 133
5 votes
2 answers
5k views

Repository pattern along with EF and Unit of work

I'm new to this Repository pattern and have seen lot of repository pattern + UoW implementations all over the internet and I'm not able to reach to a conclusion as to which of them is correct . After ...
Codebadger's user avatar
3 votes
2 answers
1k views

Entity Framework Lazy loading performance comparison

The following code takes about 20 seconds to run with about 200,000 records in the TaskLogs table: ...
Kappacake's user avatar
  • 135
1 vote
1 answer
94 views

Controller with TemplateService

I am working on my template web api project. I just wanna hear any suggestion how to improve this code. I heard that repository pattern is anti pattern so I want to make code without it. Any opinion ...
Wiktor Dębski's user avatar
4 votes
1 answer
8k views

Injecting a DbContext with an async constructor dependency

The goal is to construct a DbContext with a connection that uses an access token. The access token is acquired with ADAL (Active Directory Authentication Library). ...
Stijn's user avatar
  • 313

1
2 3 4 5
8