Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
38 views

Pull records of people from database [on hold]

So as the title suggests, I am really just looking for feedback/alternatives. This is a practice more than anything. So essentially my goal was at the very top of the application, I have (even though ...
2
votes
0answers
100 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 ...
1
vote
0answers
181 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 ...
3
votes
1answer
47 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. ...
1
vote
0answers
231 views

Dynamic AuthorizeAttribute with database

I want to create a AuthorizeAttribute that gets the current ActionMethod RouteData and ...
2
votes
0answers
90 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", "...
2
votes
1answer
1k 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 ...
0
votes
1answer
104 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 ...
2
votes
0answers
37 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 ...
-3
votes
1answer
85 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. ...
-1
votes
2answers
72 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 ...
1
vote
1answer
385 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 ...
0
votes
0answers
44 views

EntityFramework Core Setup

I'm brand new to Entity Framework. I'm a 16-year-old self-taught student that didn't really have the funds to professionally learn how to code, therefore I probably missed certain topics, which is why ...
5
votes
2answers
2k 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 ...
3
votes
2answers
595 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: ...
1
vote
1answer
63 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 ...
2
votes
1answer
1k 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). ...
0
votes
1answer
421 views

Navigation properties with sql/dapper

I want to have the same experiance with slq/dapper for my navigation properties just like in Entity Framework. But I'm not sure which sql query i should use. As you see, every single Resource entity ...
2
votes
1answer
833 views

Service Layer, using Entity Framework 6.2

I would like you to review a part of my warehouse application, a Service Layer to be exact. The architecture of the program is: DB --> .Data (EF's DbContext/...
0
votes
1answer
643 views

How to optimize a nested foreach loop which is creating same data object (with different values)

I have following code which gets MastrSegments from repository(entity framework). It's working but I think I am violating DRY (though not sure). MastrSegments conatins collection of SegReqs and ...
2
votes
0answers
634 views

Entity Framework with two databases (with UoW, Repository and Service Layer)

I have two databases: one for a warehouse, second for the office (The db design is out of the scope of this question). There are MANY cross-database funtions. One of those functions is ...
0
votes
1answer
55 views

Data validation for to check required fields are mapped

Can I break the below foreach and IF statements into LINQ expression. Also, performance wise which will be better. Please suggest. ...
2
votes
0answers
96 views

EF mapping complex type to JSON in DB

I am trying to map a complex type to Json and store the info as Json in the DB using EF6 Code First. Here's what I have for now: The complex type ...
1
vote
0answers
42 views

Querying a database to find notifications to comments

I have a solution what I think is not the best, and I want to make this not so expensive. I'm using MVC 5 + SignalR (hubs) + EF + UnitOfWork + Generic Repos. I have a table ...
0
votes
1answer
323 views

Entity Framework MVC updating db using a repository method [closed]

I have inherited this code from a legacy project, and it is throwing a New transaction is not allowed because there are other threads running in the session. error. Now I know the problem here is ...
2
votes
1answer
262 views

Creating a simple unit of work with Entity Framework and no repository

I've been trying to implement a .NET MVC Unit of Work API (rather than creating a separate repository), but it doesn't feel right. Am I going about this the correct way? Following advice from here. ...
1
vote
1answer
62 views

Search through multiple lists, but have functions that do that in parts

I have an Entity Framework table of Addresses. I'm building a Repository that would allow me to search for an Address by either parts of the Address or the whole address. Here's what I've got so far: ...
2
votes
0answers
490 views

Dynamic context.Set load and update/insert with using dynamic field in C# entity framework

I am writing an importer service. I have different sources and at the end I would like to push them into database tables. For different db tables, I am using different dbset in the context. I also am ...
1
vote
1answer
129 views

Calculating difference in time

In table first value I have value with datatype = Start I need to calculate difference first value - midnight Last value is ...
0
votes
1answer
347 views

EF Core Complex Query Method

The code is returning reviews based on users like status order. It seems it executes a lot of SQL queries, so do you think it can be simplified and can it be a headache to server performance? ...
0
votes
1answer
902 views

use Identity value in entity after insert in Database [closed]

i want to generate value using current date and ID of inserted entity problem is that ID value not generated until insert object to database, so i use this code for generate value: ...
3
votes
2answers
144 views

Getting a serial number from shared table

I have a table that keeps track of a global serial number shared between several tables. This is not the PK or unique id for each table. It is like a case identifier. Every time users create a new ...
1
vote
1answer
110 views

Performance concerns for synchronous action methods

I have an ASP.NET MVC 5 application using Entity Framework with SQL Server 2016. The application is mainly basic CRUD. The boilerplate generated when creating the project in Visual Studio did not have ...
2
votes
0answers
141 views

Domain Driven Design Model for handling images

I have to create model which will handle various types of images in my app. INTRO Plan is to have one Image type which will be universal and then extended with ...
5
votes
2answers
10k views

C# - Entity Framework + Repository pattern + Unit of work pattern

After hours spent on reading various articles about correct way to implement Repository patter & UoW patters I finally think that I have managed to create (hopefully good) implementation. The ...
1
vote
1answer
8k views

Entity Framework - Add or Update Parent Entity with Children

This code saves an DomainEntityRecord (parent) and DomainEntityDetailRecords (child), and it works. It feels odd that I get the ...
6
votes
2answers
6k views

Get total count of object's elements and all children objects` elements

I have a table, Taxonomy, with data that looks something like the following: ...
2
votes
1answer
502 views

Entity Framework - Table structure, navigating many descendants, etc

Someone suggested to try asking this here instead of stackoverflow, so I'm taking their advice. So I'm rewriting a dated application and trying to structure things the right way. I have a Category > ...
2
votes
1answer
70 views

Adding data to database using ASP.net and SQL-server part 2

This is a continuation of my question in this link: Adding data to database using asp.net and sql-server. Now I have already incorporated the solutions that was provided in the given link. First ...
3
votes
1answer
81 views

Adding data to database using asp.net and sql-server

I just want to know your suggestions on improving my code on adding data to the database using asp.net and sql-server. Basically, I've created a form that the admin will fill-up and then when he ...
6
votes
1answer
980 views

GroupBy(params string[] fields)

Linq to Object GroupBy extension method allows grouping by projection: ...
1
vote
1answer
512 views

Counting matching rows in IQueryable

I'm designing a basic ticketing system using ASP.NET MVC with Entity Framework. I'm passing a DbSet<TicketModel> into a method as an ...
2
votes
0answers
1k 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: ...
2
votes
1answer
621 views

Retrieving values from Entity Framework DbContext to render in a ListBox

I need to pass a ViewModel to a strongly typed View which will display a multiple-select box using Html.ListBoxFor. My ViewModel has a ...
1
vote
2answers
113 views

Implementation of many-to-many relation Tag Table

I have belowe tables, for Map string[] Tags from ViewModel to Model I'm using Below codes : ...
2
votes
1answer
847 views

Check if item exists

I have a service to Insert TagName , I dont want to insert duplicate tags I used this : ...
2
votes
1answer
2k views

Saving WPF DataGrid changes to Entity Framework

I feel like I had to invent a whole new way to do this because I couldn't find anything that did this the way I wanted to... The basic process involves reading changes to cells and capturing ...
1
vote
0answers
25 views

get ProductFilters in hierarchy table

I have two tables : Category and ProductFilter. Category table is hierarchy and I have depth ...
0
votes
0answers
2k views

Best practice for handling DbContext (Entity Framework)

I have recovered a project in ASP.NET MVC 5 uses a SQL database SERVER 2016 and Entity Framwork 6. In this code we will create a new instance of the DataContext whenever he wants to use an entity. ...
4
votes
1answer
313 views

Wrappers For Performing SQL Transactions

I am trying to make my ASP.NET MVC application use transactions for all database operations, to ensure safety when there are multiple users. To do this, I have created static methods in my ...