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.

0
votes
0answers
14 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
85 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
73 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
6k 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
25 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
74 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
110 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
375 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
70 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
89 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
149 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
180 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
138 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
66 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
206 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
121 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
185 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
213 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
271 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
424 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
318 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
111 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
385 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
265 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
813 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
191 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
190 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
252 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
520 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 ...
3
votes
1answer
4k 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
471 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
687 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
825 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
270 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
93 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
109 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
87 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
955 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
241 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 ...
-5
votes
1answer
341 views

Microsoft Entity Framework - when to use it? [closed]

I am researching Microsoft entity framework and I am confused about when it should or should not be used. I am interested in the relationship between entity framework and product management ...
3
votes
1answer
5k views

Dependency Inject DbContext into MVC Controller

I'm having some concerns about injecting my Entity Framework DbContext into my MVC controller. Below is a sample of my code. The way I designed this is so that I can better unit test my Controller ...
1
vote
0answers
283 views

Multi-Tenant & Multi-Object Permision Suggestions

I am looking for suggestions/examples on how to setup permissions for my project. I am using ASP.NET Core 2.0 with EF Identity 2 (on one server) and will be using IdentityServer4 (secondary server) as ...
0
votes
3answers
151 views

Designing a CMS. When to use interfaces properly and dependencies and layering

I am building a CMS and need guidance on how to structure the application. I simply do not understand when I should use interfaces or an abstract class. The system being built is using .Net Core and ...
1
vote
0answers
295 views

Moving Role CRUD operations from the Controller to the Application Service

I am creating an administration facility for an asp.net MVC application. I am currently trying to create a form that will allow admin users to create roles. I see plenty of code, which looks like ...
-2
votes
1answer
761 views

How do I use the same entities in multiple projects with the entity framework?

I have to create two different projects with the Entity Framework: Web API Services UI and Business Logic (MVC). Both the projects have to work with same POCO entities. I see two alternatives and ...
0
votes
0answers
353 views

C# EntityFramework 6 DbContext and data service with dependency injection

I am refactoring an application that collects and displays measurement data that is stored in a database. Currently I have an interface calleIMeasurementsDataService and an implementation ...
1
vote
0answers
789 views

Entity Framework naming conventions for the same table name across multiple schemas

The DbContext of my application's Entity Framework setup (which I will refer to as ApplicationContext, the name of our derived type) contains classes for all of the tables in our SQL Server database, ...