Questions tagged [entity-framework]

Entity Framework is a LINQ-based object-database mapper for .NET. It supports change tracking, updates, and schema migrations for many databases. Please add a version-specific tag as well.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
16 views

Database tools for Visual Studio and .NET Core [closed]

In Visual Studio for the .NET Framework, we had a robust set of tools that were part of the Visual Studio deliverable (ADO.NET Entity Data Model) that made it easy to generate classes to connect to a ...
pat capozzi's user avatar
  • 1,410
-1 votes
0 answers
22 views

Create a SqlExpression that includes a subquery

I'm looking into using IMethodCallTranslator to map a custom function so that I can use it in Entity Framework queries. My implementation of IMethodCallTranslator.Translate() needs to return a ...
Jonathan Wood's user avatar
1 vote
0 answers
29 views

Serialize object with newline character in string property gets undesirably escaped [duplicate]

This question has nothing to do with the suggested duplicate question. The answer for that specific question is that the debugger in Visual Studio escapes JSON strings. I already outruled this by ...
JKL's user avatar
  • 988
-1 votes
0 answers
16 views

.Net Entity Framework Unable to connect and open database with SQLite

Applied Steps: Generate a migration for creating the database tables (dotnet ef migrations add InitialCreate --context PizzaContext) Apply the InitialCreate migration (dotnet ef database update -- ...
user12272065's user avatar
1 vote
3 answers
45 views

Entity Framework Core: The INSERT statement conflicted with the FOREIGN KEY constraint

I'm working on an ASP.NET Core application using Entity Framework Core, and I'm encountering an error when trying to insert data into my database. The error message I'm receiving is: "...
Blessing's user avatar
0 votes
1 answer
24 views

Extract property from a List and insert into another table

I have a table called Personel, each Personel contains a List<Eblagh>. Inside this there is a property named Vahed. I want to find all the Vahed that are available in personels (eblaghs), and ...
Katana's user avatar
  • 754
1 vote
3 answers
63 views

Improving the speed of a query?

I am trying to improve the performance of a query. I was thinking of using AsNoTracking(), but I am not sure if the location where it is put will make a difference i.e.(before Select() or after, ...
AkshatSparrow's user avatar
-3 votes
0 answers
21 views

Conversao usando Dapper [closed]

eu estou criando uma API para praticar e me deparei com um problema nos metodos de busca, na minha Model de Produtos, `public class Produto public class Produto { public int ID { get; set; } ...
vlad Neres's user avatar
0 votes
0 answers
26 views

Problem with DateTime in Asp.net Core Entity Framework

The DateTime field is defined in the token's Claim, however when I try to retrieve it's value it does not exist, I know there is a problem when saving DateTimein Postgres due to time zones. My Program....
Heflain R. Mendes's user avatar
-1 votes
1 answer
54 views

Entity Framwork Core is failing to retrieve data when I'm trying to call an extension method in the query

When I have the following EF query which is failing to retrieve the data from the db. var results = await (from a in agreements let showPasscode = <snipped> ...
Pure.Krome's user avatar
  • 84.8k
-1 votes
1 answer
28 views

need help linq query [closed]

I used this code in vb.net 2022 to update data in my database, but it updates only one column in the time. How can I make it update all columns in the time? I am very new with linq. Dim x = (From ...
ABDULAZIZ DHAW's user avatar
0 votes
0 answers
27 views

How to Implement SQL Server Always Encrypted with "ErikEJ.EntityFramework.SqlServer" and Azure KeyVault in ASP.NET MVC 5?

I have an existing ASP.NET MVC 5 web application that uses Entity Framework 6 and targets .NET Framework 4.7.2. I want to implement SQL Server Always Encrypted using the "ErikEJ.EntityFramework....
Libin TK's user avatar
  • 1,477
3 votes
2 answers
147 views
+250

Writing custom Entity Framework function with IMethodCallTranslator

I have a query that looks something like this. var railcars = DbContext.Railcars .Select(r => new { Number = r.RailcarNumber, Quantity = railcar.InboundQuantity -...
Jonathan Wood's user avatar
0 votes
0 answers
30 views

Retrieving data from a secondary table that is joined to the primary one via the primary key in both

I have an ASP.NET Core website that I'm trying to build from an old webforms one. There is currently a one-to-one table relationship where a main ASPNETUsers table joins to a POC table via the same Id ...
Levi Wallach's user avatar
0 votes
0 answers
16 views

Unable to connect EntityFramework to DB2 Provider

I have been trying to migrate to another computer while also upgrading from VS2012 to VS2019... so far I have upgraded target framework from .Net v4.0 to v4.7.2. As well as EntityFramework is v6.4.4 ...
wawo's user avatar
  • 37
0 votes
2 answers
42 views

How to join without foreign key constraint in Entity Framework

I have a situation where it would make a lot of sense to have a couple of generic foreign keys. That is, columns that contain the ID of another table without defining foreign key constraints. In the ...
Jonathan Wood's user avatar
-1 votes
0 answers
16 views

Adding discriminator to EF table, that already contains rows

What will happen if add inheritable class to base class, that represent EF(EntityFramework) entity and the table in DB that store rows for that entity already contains rows? How the discriminator will ...
heyJoe's user avatar
  • 569
-1 votes
0 answers
32 views

EF.CompileQuery: 'The LINQ expression ... could not be translated'

I have a function something like this public static Func<DBContext, ViewType, IEnumerable<DBObject>> GetVehicles = EF.CompileQuery((DBContext context, ViewType viewType) => ...
Levyi's user avatar
  • 17
0 votes
0 answers
20 views

Entity instance cannot be tracked because another with the same key value is already being tracked. DDD + CQRS + EF Core

I am more or less following Microsoft's DDD and CQRS patterns example (eshopOnContainers app) to build my application. I have the following main components: Application Layer/PostTransactionService ...
Serge's user avatar
  • 31
0 votes
1 answer
29 views

Stored procedure output parameter value is null (entity framework)

I am trying to call a stored procedure from entity framework but I am unable to get the output parameter value. It is always returning null. Here is my code object[] parameters = { ...
Razi Gohar's user avatar
0 votes
1 answer
40 views

ASP.NET 6 input validation: unique column on create - but validation problem on update

I have a table with key Id, and have a unique column (Name). When creating a new row, the Name must be unique. I created a custom validator. public class UniqueNameValidationAttribute : ...
Sandor.Oros's user avatar
1 vote
1 answer
29 views

Angular JS Routing is not working in ASP.NET MVC and Web API project

I have two main ASP.NET MVC controllers: Home and User. Home has an Index method that is returning an Index view which is main page for loading partial pages (User Detail, Facility, Login Page) in ng-...
Maryam's user avatar
  • 13
2 votes
1 answer
84 views

EF Core QueryExpressionInterceptor for DayOfWeek

We had an existing application using ASP.NET MVC and EF6. We migrated to ASP.NET Core and EF Core 7. As title suggests, we are having trouble with existing queries where DayOfWeek is used. DayOfWeek ...
Dharmesh Tailor's user avatar
0 votes
2 answers
58 views

Simple way to only return the ID of child objects

I have an ASP.NET Core Web API. I included the controller and the object that I would like to return. The problem is, this object can have a lot of children that in turn can have a lot of children. In ...
Bas Visscher's user avatar
0 votes
1 answer
32 views

.Net Entity Framework Creating Reference Loop and Failing

I have a Blazor WASM Core Hosted app that I am trying to setup a one-to-many (optional with the many) using Entity Framework. But this is causing a circular reference error, and I am not sure why. ...
jason's user avatar
  • 3,633
0 votes
0 answers
39 views

Why is there no UpdateRangeAsync in EF Core [closed]

I am working with Entity Framework Core. I noticed something while doing database operations here. There was AddRangeAsync method but there was no UpdateRangeAsync method. What is the reason for this? ...
Kamohobe's user avatar
1 vote
2 answers
109 views

How can I reorder list of item with Order column and update list with EF Core?

I have list of object like this in database: List<YourEntity> entities = new List<YourEntity> { new YourEntity { Id = 1, Name = "Item A", OrderColumn = 1 }, new ...
Faraz's user avatar
  • 844
0 votes
2 answers
75 views

Entity Framework returns null after update the entity

I am new in Entity Framework and trying to update entity and return it with its relations. First of all EF doesn't return the entity with its relations. It only returns itself, so i decided to first ...
mehmetserif's user avatar
  • 1,197
0 votes
0 answers
23 views

How to handle entity changes that should trigger changes to other entities in EF?

We're in the midst of developing a C# application that leans on Entity Framework, structured around the classic Controller -> Service -> Repository pattern. One of the challenges we face is the ...
JamesG's user avatar
  • 134
0 votes
1 answer
45 views

C# EF Core - Query must contains all in the List<object>

class OrderItem { public long Id, public int Qty, public long ProductId } class Order { public long Id public ICollectable<OrderItem> Items = new List<OrderItem> } var dtos = ...
Fransisco Wijaya's user avatar
0 votes
0 answers
20 views

EF 7 Code First Entity with Object Property having Relationship

I have a project that I am playing with using Code First, and I have a few objects that utilize a ProcurmentData class which has a relationship to a Supplier: public class ProcurmentData { public ...
J.Kz's user avatar
  • 1
-2 votes
0 answers
52 views

Same query on Entity Framework 6.2.0 doesn't work on different versions of SQL Server (2014 vs 2019)

I have the following query on Entity Framework 6.0.2: List<SolicitacaoDesenvolvimentoInfo> sds = Uow.Context.SolicitacaoDesenvolvimento .Include("StatusAtual") ...
Matheus's user avatar
  • 65
0 votes
0 answers
54 views

How to fix LINQ Query from generating OR is NULL condition in C#?

I have a LINQ Query that is pretty simple at the code level: var r = _repo.Filter<ResultData>(a => (a.TrackingIdentifier != null && (a.TrackingIdentifier == ...
Unconquered82's user avatar
0 votes
0 answers
14 views

No DbContext was found in assembly

I am a frontend developer. Another developer gave me a working code base. I run these commands for setup: dotnet restore sh setup_script.sh Where setup_script.sh contains: export password=root export ...
Daniel Sadovskiy's user avatar
0 votes
1 answer
51 views

.NET Core Context inheritance IdentityDbContext with scaffold-dbContext command

I want the context that will be created in this scaffold command to inherit IdentityDbContext, not dbcontext. How can I specify it as inheritance? So public partial class OrderSystemVContext : ...
Berat's user avatar
  • 23
0 votes
1 answer
41 views

.NET Core Scaffold-Dbcontext without Identity Tables

I am trying out a project. I am using the Identity system in this project. First, I created Identity and DbContext by migrating to SQL Server. Now, create a table on SQL server and scaffold-dbcontext &...
Berat's user avatar
  • 23
0 votes
1 answer
37 views

How to use Entity Framework raw query with PostgreSQL in .NET Core 5?

I am working on a project to switch from SQL Server to PostgreSQL in my .NET 5 application. I have to use raw queries for the existing code. Here are 2 packages I am using: <PackageReference ...
Zichen Ma's user avatar
  • 905
0 votes
0 answers
22 views

Adding migration to a context in a separate class library?

I have a separate Assembly with several data types and a DBContext-derived class. It's set up to be used in several websites but each website can specify which database server to use. Choices are ...
Wim ten Brink's user avatar
0 votes
1 answer
65 views

EF Core GetAll entries does not include referenced objects for all entries

I have a problem with EF where when I get all entries which has a list of associated activities. Then it is only the last Entry which references the particular activity, which has the activity in its ...
Theodor349's user avatar
0 votes
0 answers
31 views

Data not updating when i download a form

PDF data not dynamically changing according to inserted data **i have an app in which I have models , controllers ,interfaces and manager classes all are in C# maybe from the code you can understand ...
Syed Basit's user avatar
0 votes
1 answer
25 views

DbUpdateConcurrencyException in Outbox MassTransit

We are currently using MassTransit and MassTransit embedded Outbox with generally successful results in our development and testing environments. However, when we transition to the live environment, ...
rezriverty's user avatar
0 votes
0 answers
32 views

EF Core change tracker stores same reference for Current and Original value of complex property

SO shows possible duplicates for my question, but I'm not quite sure my case (and actually the question itself) is the same. I have an entity with complex property, let's say public class Entity { ...
dotFive's user avatar
  • 363
0 votes
0 answers
40 views

How to map an object inside another object using Automapper?

I'm trying to do the mapping to display a value that is inside an entity, which is inside another entity that is inside another entity, the sequence is "Hose" > "Equipment" > ...
Guilherme Costa's user avatar
1 vote
1 answer
39 views

Entity Framework 6.4.4 is unable to generate Entity Classes from EDMX through 'Run Custom Tool' option. Visual Studio 2022

I have created two tabled in the database and I was able to add them to the Edmx by updating the model from the database, however, the entity classes for the tables that should've been generated are ...
mfs's user avatar
  • 3,994
0 votes
0 answers
37 views

Store object that has a List of objects as a property, without these objects generating a seperate table

I have this class that has 2 complex properties: public class App { [Key] public Guid Id { get; set; } public string StringId { get; set; } = string.Empty; public string AppName { get; ...
Nono-Man's user avatar
-2 votes
1 answer
23 views

I want to save QrCode as image

this the code [HttpGet("GenerateQrCode")] public ActionResult<string> GenerateQrCode(string sellername, string vatregistration, string timestamp, string invoiceamount, string ...
asmaa hamed's user avatar
-1 votes
2 answers
41 views

How to check a date to make sure it is not in the future tense without dropping the app on WPF with EF

I have an app that maintains the database which contains people with their data. Like phone number, date of birth, address etc. I want to fix one of the bugs... I need to add only existing date of ...
 XedDevil 's user avatar
0 votes
1 answer
43 views

Entity Framework Core - Creating multiple identical records with a given object

I receive data of a list of items and ONE person from user input The order table will have links to item and person. I will need to create order record linking each item and the person. However, I ...
jojo gomez's user avatar
1 vote
1 answer
39 views

Two fk's to same table

I have an old desktop system, and I'm refactoring with backend with C# using EF Core. In the old database, there is a table to define a complement product. I have two columns, and it's using the same ...
Amilton da Cruz Machado's user avatar
0 votes
1 answer
92 views

The SQLite provider of Entity Framework sometimes does not perform the insert

The command should be executed in a specific order, not as a query. I checked the log when the InitializeAccount method was running. The dbContext only inserted 2 TaskTypeModel. I expected the order ...
david's user avatar
  • 3

1
2 3 4 5
1831