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
2
votes
3answers
142 views

DataAccess Layer coupling with Domain Layer

We have an issue with how the implementation of the Data Access layer (EF6 Includes more specifically), influences the behavior of our Domain layer. A theoretical example to illustrate: Application ...
2
votes
3answers
81 views

Choosing between derived classes and adding an additional property in entity framework

I have the following StudentGroup class: public class StudentGroup { [Key] public int Id { get; set; } //the set of peers who will review the work of the StudentGroup [ForeignKey("...
0
votes
1answer
104 views

Call library functions with varying number of inputs while keeping API simple

For a ASP.NET Core application, I'm using a library which performs calculations using objects that have a similar interface but their constructors use different inputs. The inputs are market prices ...
2
votes
1answer
104 views

Is making your ORM DAO a subclass of your Domain Model object a viable strategy?

I am trying to separate my domain model and associated business logic from my persistence model, particularly such that the domain model has no dependency on the ORM. One apparent way to do that was ...
1
vote
1answer
96 views

Split Data logic and domain logic in POCO class?

Say for example, in this mock bank ATM app solution, I have 3 projects: UI Console Domain Model (POCO) Persistence (Entity Framework for CRUD) Domain Model (POCO): I have 2 classes public class ...
1
vote
2answers
181 views

Should an ASP.NET Web API application use Entity Framework in the API controllers?

Im a bit confused about what is best practice when working with Entity Framework and ASP.NET Web API. I am working on a project that contains a iOS/Android app and an API the app will use to ...
0
votes
0answers
16 views

how to work with variable data structures and templates

I need users to be able to create an organization which will have some preset fields such as Name, Address, and Type. But depending on the type, the organization can have type-specific fields such as ...
0
votes
1answer
41 views

Use single table with lots of columns or break it out and use Views, when using Entity Framework Core

I am currently building a game series information site and have come to a design issue. I have a table called Abilities that would have character ability information in it. Depending on the game ...
0
votes
1answer
39 views

Venue Reservation System Logic Approach/Clarification

I hope this is the right place to ask since this is a programming related question. I’m developing a venue reservation app (similar to booking.com) and am almost done however I have 1 request for ...
1
vote
1answer
68 views

Architecture for independent modules writing in the same database

Let's say I have a database with a table called "invoices". Then I have a web application where users can manually create invoices against said table. I also have a desktop application that can ...
0
votes
1answer
72 views

Is a refresh token an entity or value object?

I have a User entity, which may have a RefreshToken (for authentication). Notes: A refresh token doesn't have "identity", but is related to a single user - it is only valid for that user. In the db ...
0
votes
0answers
105 views

Real-time application and RDBMS bottleneck

I'm currently developing a real-time application using .NET Core 2.2. Many IOT devices (could be up to 100) are concurrently sending messages via MQTT. These messages are parsed, elaborated to extract ...
1
vote
2answers
124 views

Deleting each row and re-adding when saving to database

I have a structure which looks like Person ID int Name nvarchar Phone ID int PersonId int Number nvarchar Make nvarchar Model nvarchar MultiSim bit One person can ...
0
votes
1answer
66 views

Updating sub-properties via Entity Framework

I was wondering how to updated nested objects/sub-properties when using Entity Framework. But to make things clear, let's start with an example. I have an object, which can own a number of other ...
2
votes
2answers
245 views

Dependency inversion vs repository pattern (app layer dependency on ORM)

Let's say we have an application layer with some command handler and we use an Entity Framework database context/ORM context in that handler. I would invert dependencies from the Entity Framework/...
-2
votes
4answers
1k views

Mocking dbContext vs Repository [closed]

I use entity framework with Repository Pattern. while searching for means of writing unit test cases that run isolated from the database I found some people mocking the database context and others ...
2
votes
4answers
755 views

Is Entity Framework Core slower than using ADO .NET and stored procedures?

I'm looking at designing some new software for work, and I have been using EF Core quite a bit in my personal projects. In my mind, EF Core generates queries for the underlying data provider which ...
0
votes
1answer
121 views

Does a 'leaky' repository implementation defeat the point of a repository?

I've seen some tutorials and examples of implementing a repository pattern, and I don't quite understand something. My impression was that the whole point of a repository pattern was to hide the ...
1
vote
1answer
394 views

Mock a PART of EF DbContext with Moq and/or InMemoryDbSet

This question is NOT about what's here: https://stackoverflow.com/questions/25960192/mocking-ef-dbcontext-with-moq and/or similar questions. I am well aware of that. Please, read the question before ...
1
vote
2answers
412 views

How to get ORM (Ef Core) Entities follow a DDD style . Which is the best approach?

I am considering mutliple options to face a problem. I want to develop software following DDD style. The problem arise when I have to define my entities and I am working with Entity Framework Core, ...
2
votes
0answers
52 views

How to join two sets of 6 tables and select the list into another set of 6 tables

A1 |__A2 |__A3 |__A4 |__A5 B1 |__B2 |__B3 |__B4 |__B5 C1 |__C2 |__C3 |__C4 |__C5 Given a list of A and a list of B, we want to "join" ...
5
votes
2answers
1k views

Should AutoMapper be used to Map from ViewModel back into Model?

Should AutoMapper be used to take data from ViewModel and save back into a database model? I know the opposite practice is good software practice: to have Automapper to extract database models, and ...
0
votes
0answers
38 views

entity framework code first and common table in linked server

We are working on a system with several applications and we have several link servers. Every application has its DB on a server. Sometimes it's necessary for applications to use table of other DBs. ...
6
votes
2answers
2k views

Should Entity Framework 6 not be used with repository pattern?

So I am asking this after reading the following: Why shouldn't I use the repository pattern with Entity Framework?. It seems there is a large split of people who say yay and those that say nay. ...
0
votes
1answer
310 views

Entity Framework and static entity instances

I'm always having the problem on how to properly design having static entity instances and it being attached to Entity Framework's Dbcontext. For example, we have the following: using Microsoft....
-1
votes
1answer
29 views

where to put business constraints

We have a 3-tier architecture: Web, Business, Models using the MVC pattern. Models are Code-First using EF6. Currently we access the dbContext directly in our Controllers to query and save changes. We ...
1
vote
3answers
130 views

Tracking state on entity and unit-of-work pattern

In my web app I have a long running operation that is processing some entity in the background. The state of this process should be visible to the clients. During the processing the UI should show ...
4
votes
3answers
157 views

Is a repository return a graph of entities violating SRP?

I'm working in this scenario Post entity has many Image entities. I also have repository to both entities: PostRepository ImageRepository Since this entities are tightly related, when I get a Post ...
3
votes
7answers
2k views

Should I use entity framework for CRUD and let the database handle the complexity that comes with high end queries?

I am new to ef and liking it since it reduces the overhead of writing common queries by replacing it with simple add, remove functions. Agreed. Today I got into the argument with my colleague who has ...
-1
votes
1answer
89 views

Patterns for loading related objects in memory (without an ORM)

I am using ADO.NET to read a bunch of data from the database into in-memory objects. This is my domain model: // Question.cs public class Question { public int ID { get; set; } public ...
9
votes
5answers
3k views

Pitfalls of Domain Driven Design with Entity Framework

A lot of tutorials on DDD I studied are mostly covering theory. They all have rudimentary code examples (Pluralsight and similar). On the web there are also attempts by a few people to create ...
3
votes
2answers
87 views

Approach for storing lots of data of unknown type in database

I have an web app to which external applications can be connected to send their data. This is for telemetry purposes. The web app is not controlling what kind of telemetry data is sent to it - it can ...
2
votes
3answers
724 views

Should Data Access Layer surface return Data Transfer Objects or return EF Models?

So say I have a controller Method // GET: TimeEntries [HttpGet("[action]")] public IEnumerable<TimeEntryDTO> GetLast(int value) { return dal.GetLast(value); } And a ...
1
vote
1answer
224 views

c# What problem will happen when i use static class for access database?

Many place that i have read about static method they said please shouldn't use static method for access to database and should use dependency injection for inject other service and use that service to ...
1
vote
1answer
143 views

Can I use Entity Framework with a SOAP API layer over a database?

We have a hierarchical database at our institution that has exposed a SOAP endpoint as the only way to make CRUD operations against it. We are primarily a .NET Core shop. I'm trying to conceptualize ...
1
vote
2answers
68 views

Structural problem related to Dependecy Injection and Asynchronous Operations

I'm implementing the onion architecture with webapi, service layer, repository, unit of work and the domain classes. I use also DI, using simple injector. But my issue, is how can I implement a ...
2
votes
1answer
820 views

How should I design a 3-tier-architecture application with Entity Framework?

This is almost getting me crazy. EF bring us a very convenience experience in development. However, if we need to use the Entity model in the upper layer, we always put a reference from the upper ...
1
vote
1answer
110 views

Using Entity Framework with third party applications

In my current situation I am one of two developers at a manufacturer. We have been extending the functionality of existing applications (ERP and some others). These third party applications do not ...
3
votes
2answers
3k views

Separating Domain Object and Data Models

I looked through a lot of articles, blogs, and SO topics about separating domain object and data models. Almost every answer said: You should have separate classes for the domain and data persistence, ...
4
votes
3answers
497 views

Should I merge database migrations together before release?

During the development process many migrations may appear. Is there any point to keep them instead of merging them all together? Let's take a look into a simple example. During development we ...
32
votes
5answers
17k views

Should I check if something exists in the db and fail fast or wait for db exception

Having two classes: public class Parent { public int Id { get; set; } public int ChildId { get; set; } } public class Child { ... } When assigning ChildId to Parent should I check first if ...
1
vote
1answer
518 views

Entity Framework - extending OR injecting services into DB Context

I fear I'm asking a somewhat silly question, but I'm now completely lost as to which principle I should follow. To my understanding - in terms of Single Responsibility Principle it's best we don't ...
0
votes
2answers
629 views

In Entity Framework how do I wrap a database call with a call to another service and ensure they're always called together?

I have an entity framework model called Employee. Whenever I request a list of all Employee rows I first want to make a soap request to get any new employees from another system and update the sql ...
1
vote
4answers
926 views

Why do people prefix property names with class names [closed]

Especially when working with some kind of ORM like Entity Framework I often see classes like: public class Foo { public int FooId { get; set; } } accessing the id will look like foo.FooId Is ...
0
votes
1answer
144 views

How to properly wrap my data layer to communicate with business logic

I have an EF Core data layer and i want to wrap it around an interface to separte it from the business logic. Now the issue is that i am not sure i am doing it correctly. First, i was just using ...
0
votes
3answers
100 views

Updating nested entities with constraints without getting spaghettimadness

I have an endpoint "import" that is supposed to accept an entity. This entity can contain several sub-entities with yet again some sub-entities. Since this is an "import" endpoint, some of the entites ...
5
votes
2answers
243 views

Is it worth implementing Entity Framework when calling a single stored select?

I'm currently building a web application for my enterprise level business internship. This web application will track data from three different sources: a DB2 database, a SQL Dynamic database, and an ...
2
votes
3answers
9k views

Repository Pattern and Joined Queries

In conjunction with Unit Tests and Dependency Injection I (and my primary coworker) are exploring Repositories. However we cannot come to a solid plan of action for implementation. In a basic ...
2
votes
1answer
412 views

Best practices for translatable models in Entity Framework Core 2.1+

I'm building an Entity Framework Core-backed ASP.NET Core RESTful service and I have entities / models such as Product, Document etc with description in multiple languages. I want to be able to ...
1
vote
1answer
286 views

Entity Framework Entity Names

As an example, I have a POCO called Person which is used in my presentation layer and my business logic layer. I don't want to use this POCO in the Entity framework because I don't want that class ...