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]

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

2
votes
2answers
56 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 ...
1
vote
3answers
111 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
136 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 ...
-3
votes
0answers
51 views

Scheduler that goes through thousands of data every 10 minutes, is it better to do recursively? [closed]

I have a scheduled task that runs every minute, that processes thousands of data. It is currently programmed this way: var data = _context.jobsData.Where(predicate).ToList(); // query usually ...
1
vote
1answer
34 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
59 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
131 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
48 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 ...
0
votes
0answers
25 views

Design for Handling Spatial Data using EF Core and MySql

So EF Core support for spatial data is practically nonexistent at the moment. The majority of work that has been done is about to drop in the 2.2 Preview 3 which is fantastic news. However, it's ...
3
votes
2answers
121 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, ...
2
votes
3answers
85 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 ...
26
votes
5answers
7k 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 ...
0
votes
0answers
38 views

Object mapping vs projection with ASP.NET Core

Many examples I see using ASP.NET Core involve one or more of the following: Web app or api that configures a DbContext via dependency injection. A class library that contains a Entity Framework ...
1
vote
1answer
165 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
121 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 ...
2
votes
4answers
399 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
74 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
94 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
153 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 ...
0
votes
3answers
506 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
179 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
98 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 ...
-1
votes
1answer
275 views

ORM vs Web API differences

I'm struggling to understand the differences between an API such as a REST API and an ORM such as Entity Framework. I would also like to understand the benefits of each and in what situations either ...
0
votes
1answer
131 views

Is my DataAccessLayer well implemented?

I have 3 projects in my solution : An ASP MVC project A console app project A class library project (the DataAccessLayer) I didn't want to recreate an ADO.net entity data model for each project so I'...
-2
votes
1answer
186 views

Convince manager, to switch from EF db first to code first

I really hate dealing with DB first, it is honestly the bane of my existence. How can I convince my manager that, although the work to switch is a lot. It will be worth it.
-2
votes
1answer
217 views

Role-based declarative security for C#

According to Domain Driven Design and Development In Practice: Spring Security (a sub-project in Spring Portfolio) provides a fine-grained access control in both presentation (URL based) and ...
-1
votes
2answers
416 views

Nullable foreign keys and creating join tables

I'm not that experienced in sql modeling and i'm looking for input on this because it's important for me to get it right. I use mssql and entityframework core in an asp.net core web app. The app ...
0
votes
0answers
56 views

How to implement M-N relationship to reflect the domain correctly

If I have three entities like this: WorkingGroup WorkingTime Shift The WorkingGroup has one or more workingTime public class WorkingGroup { public WorkingGroup() { ...
-1
votes
5answers
444 views

Is it good practice to have a unit test for a simple data method?

I have a simple data method that does this: public void Write(Foo foo) { db.Foos.Add(foo); db.SaveChanges(); } I was asked to write unit tests for this. To do so, I had to create a fake ...
6
votes
4answers
331 views

How to incorporate external entity models in conceptual model?

If I want to create a conceptual model for my new application, and during the analysis, I found that some objects like employee, department ..etc are a part of another system. and all the data related ...
-1
votes
1answer
115 views

Iteration inside a using or using inside an Iteration

Is there a best practice for iterations inside of a "using"? which is better? and maybe a why? "using" inside of an iteration... foreach (var currentPerson in Persons) { using (var db = new ...
1
vote
1answer
484 views

Manually disposing Entity Framework Context while using Ninject InRequestScope();

Spending some time sifting through documentation, I'm trying to figure out the best software architecture with or without the dispose pattern. I've built the Repository pattern many time over the ...
-2
votes
1answer
340 views

About Three Layer Architecture

I'm currently developing a minor project for school and I'm supposed to use a three layer architecture in the project. I'm working with C# in .NET and I'm also working on Windows Forms, and with the ...
0
votes
2answers
1k views

Storing a temporary data outside of DbContext in Entity Framework

I have a performance issue with a few methods in my Service Layer. Methods that are causing me troubles have some logic, but it's db connection that takes over 95% exec time. The problem is ...
0
votes
0answers
209 views

Integration Tests of Entity Framework's Fluent API

I have a project using EF6, that was build after the database, but its EF is not DB-first. It's a reversed code-first I would say. The database is very big and really messy, so I didn't want ...
1
vote
0answers
200 views

Create A Complex Resource Atomically With Nested Objects Through REST

Background: There is a UI Client and REST Webservice. The user interface form allows you to create a complex object. The complex object is composed of primitive types (string, integers,...), and ...
0
votes
0answers
28 views

Designing a Data Model For Climbing Gear Checked Out at Events

I am trying to setup an internal use asp.net core 2.0 application to check gear in and out at climbing events. The Model will go something like this: Category.cs (like ice, mountain, etc...) ...
0
votes
4answers
296 views

Avoid type checking but preserve separation of concerns

I'm working on an MVVM project and trying to preserve separation of concerns. Our current architecture has an entity framework model and MVVM light view and viewmodel projects. I'm working ViewModel ...
3
votes
1answer
590 views

Managing Database Access for MicroServices

We currently have a work stream where we are splitting out a Monolith into microservices and there has been a debate as to how we will access and persist data. To give you a good idea of how most of ...
4
votes
1answer
5k views

Generic repository pattern +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 ...
0
votes
1answer
599 views

What is the best practice for API endpoints for an entity?

I don't know if the title is reflecting the question correctly, but I can explain more than write a good title. If I have a database that has (employees, departments, orders, etc...), and have ...
0
votes
4answers
803 views

Concurrent database access on shared network drive

I'm part of a small team that currently uses an Access database for scheduling a larger team's availability. This has presented some issues with corruption of the Access database. Additionally, I want ...
1
vote
0answers
956 views

Best practice for transaction handling using Entity Framework

I am developing an app which uses Entity Framework for data access. The architecture of the app somewhat like below: As depicted in the drawing, the business service can be consumed from either web ...
1
vote
1answer
307 views

Questions about business logic layer and data access layer in a project

I would separate the BLL from DAL as a best practice. I interact between BLL and DAL via interface. Example: public interface IProductRepository { void Add(Product myProduct); Product Get(...
0
votes
0answers
99 views

Tool to automatically implement Repository pattern from database

I'm looking for some kinda of tool, that will help me to code DTOs based on my database. I know, there is an automatic tool, provided by VS I don't want to use it. I'm not a big fan of "auto-generated ...
-1
votes
1answer
111 views

Connect to different database based on URL

I am developing a SAAS application where : A single web application is hosted in IIS which will serve to multiple companies and each company will have its own database. The web application and ...
0
votes
2answers
93 views

Best practice loading entity with related entities

I am trying to figure what the best practice with loading data from web apis is. Assume you have a model structure as per below: class School { private string name; private List<Classroom> ...
0
votes
1answer
40 views

Is a InMemoryDatabase suitable for store live data?

I'm learning ASP.NET Core 2, with Entity Framework Core. A real use-case scenario is a small management of a production process. I have some persistent table like customers, orders, machines, etc... ...
2
votes
1answer
1k views

Table Per Concrete Type in Entity Framework Core

I'm trying to port code from entity framework 6 (EF6) to entity framework core 2.0 (EF-Core) and have ran into a dead end. In my EF6 code, I have a base class called Record which defines the base ...
2
votes
1answer
274 views

Entity: Inherit class (or interface) or write the code

I want to figure out if its better to inherit a base class or interface or write the code up for entities. To better paint the picture assume the scenario below: Scenario: There are 30 entities All ...