Skip to main content

Questions tagged [entity-framework]

An ORM built by Microsoft and is available as part of .Net framework 3.5 and later.

Filter by
Sorted by
Tagged with
8 votes
4 answers
2k views

When using Entity Framework and running the Update-Database command, non-updated applications that rely on the database crash due to database context changes. Usually teams have a production database ...
EMN's user avatar
  • 805
1 vote
1 answer
341 views

public void ReassignLineItems(InvoiceUpdateDto invoiceUpdate) { Invoice invoiceInRepository = _unitOfWork.InvoiceRepository .FirstOrDefault(invoice => invoice.Id == invoiceUpdate.Id); ...
EMN's user avatar
  • 805
2 votes
2 answers
175 views

I'm facing a tricky situation that might result from a not thoroughly thought-out design, and I'm hoping to understand whether a deadlock might be a realistic cause – and if so, how to prevent similar ...
ComfortableOnion's user avatar
1 vote
3 answers
220 views

I am developing some modular libraries that contain common APIs, data, and functionality. One of the core assumptions to these libraries is you would use which you want to compose your project, but ...
SventoryMang's user avatar
0 votes
1 answer
402 views

Actually, in a Web API application using Entity Core, it seems very common to inject the application context to the controllers, so the controllers use directly the dbContext to do its work. Something ...
Álvaro García's user avatar
0 votes
1 answer
325 views

I am trying to apply Robert Martin's Clean Architecture on my .NET project. In one of chapters about boundary, it talks about that database interface should reside in business logic component rather ...
Afshar's user avatar
  • 223
1 vote
3 answers
849 views

This is something that I've heard a number of opinions and theories about, but I'm still torn on how to go forward. For context, this particular issue deals with the following technologies, in case ...
CrystalBlue's user avatar
3 votes
4 answers
934 views

Are the reasons for why Microsoft states that DB contexts should not be long lived because of measurable effects (memory leak, resource hog, increased probability of data corruption, ...) or is it ...
Mandelbrotter's user avatar
0 votes
2 answers
128 views

I have in project linq repository unit tests. [Fact] public async Task Get_FromTreeEntitiesUnsorted_RetunsOrderByDescending() { //Arrange _contextReadonly.Entity.Add(new ...
cargt4's user avatar
  • 19
0 votes
2 answers
735 views

I am told everywhere that entities are only to represent the data structure, then entities should be mapped to a model and then the model possibly to a DTO. The other way is similar, DTO -> model -&...
Gersalom's user avatar
0 votes
0 answers
52 views

I am looking for feedback on a design problem I encountered when processing batches of db entries. The issue at hand is efficiency and throughput of an application. The application looks like this ...
Samuel's user avatar
  • 799
0 votes
2 answers
365 views

I am currently working on implementing the Clean Architecture pattern using Entity Framework. However, I've encountered an issue related to the design of my Domain project. In this project, I need to ...
pakerinjo's user avatar
-1 votes
3 answers
3k views

My Domain layer contains below model: public class ApiResource { public bool Enabled { get; set; } = true; public string Name { get; set; } public string ClientId { get; set; } public ...
Szyszka947's user avatar
1 vote
3 answers
2k views

We have a very messy data repository component, with dozens of methods to interface a DbContext (entire database) in Entity Framework. It was (and is) coded in a way that adds a new repo method for ...
Veverke's user avatar
  • 541
1 vote
2 answers
225 views

I have a Product entity: public class Product { public int Id { get; set; } public string? Name { get; set; } public string? Description { get; set; } [ForeignKey("Brand"...
Subliminal Hash's user avatar
1 vote
1 answer
2k views

I'm trying to make an application in ASP.NET MVC. I'm using AutoMapper for the conversion between entities and ViewModels. In most cases, this works fine, but when I need to add some additional data (...
Sam's user avatar
  • 65
0 votes
1 answer
3k views

I was reading the documentation about how to use Entity Core in a DDD way. This is the documentation. It is said that I can configure EF to can map an internal private field to a private field, the ...
Álvaro García's user avatar
-1 votes
1 answer
670 views

I have an ASP.Net Core Web API where I am having difficulties designing the REST resources based on the EF Entities I have. There are three entities that describe a Reservation. First, there is the ...
J.Paravicini's user avatar
2 votes
2 answers
2k views

I have taken over the maintenance and development of a mature .NET Framework ASP.NET MVC application which uses an Entity Framework repository pattern. Several developers have worked on it before me ...
Ian's user avatar
  • 131
2 votes
2 answers
3k views

I have inherited a badly architected and organised ASP.NET MVC application, which is an online booking system for healthcare providers. It seems to have been designed with very few object oriented ...
Daniel Vernall's user avatar
4 votes
1 answer
1k views

I am designing a blog in domain driven design. I don't know how I should define models: Post and Comment. My database: A user can see a post and related comments. So I think that Post model can be ...
Aleksander Chelpski's user avatar
-1 votes
1 answer
889 views

I am building an API which, amongst other things, needs to handle users. I am building it with C# 10 and .NET 6. In order to receive/return data in the API end points, I am using records. So for ...
Jakob Busk Sørensen's user avatar
1 vote
2 answers
97 views

Here is the scenario: Let's assume that we have a Telephone and a Driver. Here is the definition of the classes (Pseudocode): Telephone: { Id: number, [Unique] TelephoneNumber: string } Driver: { ...
Replay's user avatar
  • 109
2 votes
3 answers
2k views

I have a collection of classes in a SQL database that all share the same structure, and cannot be changed. They are similar to the example below. I am using Entity Framework Core and would like to ...
AnotherDeveloper's user avatar
0 votes
2 answers
986 views

I have a class that is mapped using Entity Framework. This class has dozens of fields, and in the database there are millions of rows for this class. The class looks like this public class MyEntity {...
Ben Rubin's user avatar
  • 151
0 votes
1 answer
346 views

I have the following use case and would like to implement it in a thread-safe manner. Think of a Stack Overflow-like web application. Somebody upvotes a question. A new event is sent to the message ...
robotron's user avatar
  • 767
1 vote
1 answer
243 views

Microsoft suggests to inject ILazyLoader service inside entities in order to enable lazy loading manually in EF: https://docs.microsoft.com/en-us/ef/core/querying/related-data/lazy#lazy-loading-...
Ahmad's user avatar
  • 121
-3 votes
1 answer
2k views

I know this is a theorical question since i don't have code to or any logs to show, but i hope that someone can give me some idea on this question. The problem in question was the following: On my ...
Nmaster88's user avatar
  • 167
0 votes
1 answer
48 views

I'm currently building an API and a web app for an internal warehouse system using NET Core. I have the core entity structure, that goes like this: "Material" has many "MaterialSubtypes&...
Valhaal's user avatar
  • 13
0 votes
1 answer
4k views

For the sake of discussion, you can assume I'm using Entity Framework and a mediator pattern implementation in .NET. I'm going back and forth trying to decide how to structure some of my data access ...
Alexander Trauzzi's user avatar
4 votes
2 answers
164 views

In Entity Framework 6 and/or Entity Framework Core 3+, the code-first types generated by the scaffolding (or other code-generation tools, my preference is this T4 script) are mutable classes that do ...
Dai's user avatar
  • 678
1 vote
1 answer
877 views

I am creating a small data-driven desktop application using .NET 5 with WPF, ReactiveUI, Dynamic Data, and EF Core 5. The app uses a local SQLite database to store all persisted state, and relies ...
wired_in's user avatar
  • 332
0 votes
1 answer
712 views

I have entities in my application that require a unique human friendly identifier that include a sequence integer unique to a subset. For example, in project management software you might have a ...
Superman.Lopez's user avatar
0 votes
1 answer
2k views

I'm building a project with C# AspNet.Mvc. I'm using Entity Framework Core. It has Poco which maps in data from DB. On Mvc project itself i've got ViewModels folder where i have models topass between ...
Mattew's user avatar
  • 9
1 vote
1 answer
2k views

I am working on a project that uses Entity Framework Core. I have a class which represents an entity on which I'm trying to perform validation. Is it considered a bad practice to include a Validate ...
M.R.'s user avatar
  • 63
-1 votes
1 answer
165 views

In our database, we have around 150 different tables. However, there are a handful of them that are key, as in they get referenced pretty much everywhere. We also have quite a few reports that we pull ...
Riz's user avatar
  • 206
2 votes
2 answers
1k views

We have Application service Method, which extracts data from SQL database using Entity Framework Core . Its Async method along with the Async Controller. Service: public async Task<IEnumerable<...
user avatar
1 vote
1 answer
552 views

I have not worked with EF for a while. As an exercise, I am writing a core web api that allows keeping track of a user medias. A media can be a postcard, a photo album, a recording, a book... I would ...
Veverke's user avatar
  • 541
1 vote
2 answers
2k views

I'm very puzzled by a specific part of the repository pattern that seems simple but turn out to be tricky. I took this great explanation of this topic by Mosh Hamedani; it's a C# implementation of ...
AgostinoX's user avatar
  • 849
1 vote
2 answers
1k views

TLDR: Does using DB objects as my AggregateRoot lead to bloated God objects. In comparison to the issues I see in using separate DbObjects and DDD objects. I'm trying to bring together my ...
David C's user avatar
  • 273
0 votes
1 answer
113 views

I have been the sole developer on a project for the past eight years. Right now it's one big monolith, but at this point it's really three separate apps, and those really need to be broken down as ...
Jhorra's user avatar
  • 147
0 votes
0 answers
569 views

Our company did not properly design Address Record Code Module. Developers are updating Address SQL table with Multiple Service Methods, and are not updating AddressHistory Sql table. They're asking ...
user avatar
1 vote
1 answer
3k views

I have an ASP.NET Core Entity Framework Core application and I want to implement my own custom logger. I don't want to use ready solutions like NLog or Serilog. I added a new class library project ("...
Shrodinger's user avatar
1 vote
1 answer
556 views

I am creating a database that will keep track of my company's clients, and an app that will allow users inside the company to read/update/etc. the database. I'm using code-first EF Core to manage the ...
Craig Brown's user avatar
5 votes
3 answers
4k views

Say you have the following entity that represent an exact resource from a table, we're talking .NET Core with Entity Framework Core, code-first approach. public class Person { [Key] public ...
J.C.'s user avatar
  • 79
2 votes
3 answers
1k views

I have a problem with DDD approach for the Domain classes. Architecture Core Application (here I have a bunch of command/queries that use Domain entities and CQRS to process use cases) Domain ...
joseFrancisco's user avatar
7 votes
3 answers
16k views

I am trying to use EF6 with my project. I just watched Repository Pattern with C# and Entity Framework, Done Right | Mosh video. I understand the necessity of Repositories but I still don't understand ...
Mansur Ali Koroglu's user avatar
0 votes
2 answers
346 views

I face an issue where I want to inject Entity Frameworks DbContext into a service class, in a WPF application. The problem is that the service classes are instantiated and contained by the view models....
Jakob Busk Sørensen's user avatar
0 votes
1 answer
85 views

I've designed my app so it stores the data of each sale in the following way: each order contains different products so for each product in an order a table stores the quantity(of the product) , net ...
Diego Piscoya's user avatar
0 votes
3 answers
1k views

I have a monolith application in .net core 3.0 with entity framework core 3.0. using: a table with ~3 million records. Its structure is BusinessUnitId | ProfileId | Amount(it has more fields, but ...
Jamil's user avatar
  • 131

1
2 3 4 5
8