Questions tagged [ef-core-2.2]

Use this tag if you have questions regarding the 2.2 version of Entity Framework for .NET Core.

Filter by
Sorted by
Tagged with
0 votes
0 answers
29 views

ef core configure on delete behavior by data annotation

Trying to achieve foreign key on delete behavior by data annotation. I tried in the following way Below are my model configuration public class Course { public int CourseId { get; set; } ...
  • 90
0 votes
0 answers
72 views

EF Core - Double key with many to many relationship

Project environment EF Core 2.2.6 Many-to-Many, indirect via join table Course records already exist on the database As soon as I try to add a record to the join table, I get the following error ...
  • 15
0 votes
2 answers
280 views

How to count number of records in a var

I have the below code which is returning me a model from database. I want to know how many records are written. I am trying to use model.count or model.lenght but its not working. var model = await ...
  • 23
1 vote
2 answers
160 views

EF Core architecture vs Entity Framework architecture [closed]

I am trying to find EF Core architecture, for presentation purposes, but only find Entity Framework version like on the image below. So, is there any difference from the point of view of architecture? ...
0 votes
1 answer
309 views

Seperating Repository and Service Layer

I am working on an ASP.NET Core Web API project using EF core and would like to add Repository and Service Layers to my application to achieve Separation of Concerns. However, I still can not figure ...
1 vote
0 answers
1k views

Is it mandatory for upgrade to EF Core 6 while migrating .NET Core3.1 to .NET 6

I have a asp.net core web api project with .NET Core 3.1 target framework. This project uses Microsoft.EntityFrameworkCore -Version 2.2.6. I migrated the entire web api project from .NET Core 3.1 to ....
2 votes
1 answer
373 views

Does EF Core cache command text provided via FromSql method?

EF Core version 2.2 We have an extension method ContainsIds with raw SQL and Table-Valued Parameter (implementation below), which we are using to filter only records with specific identifiers. However ...
  • 819
1 vote
0 answers
133 views

EF Core creating an async call for HTTP PUT

Can I get some guidance on how to make these functions async? Run table record delete, then, insert new data EF Core 2.2 - I am running into concurrency issues. Routing_Tool_SO4 is the main table ...
0 votes
0 answers
161 views

How to used GroupBy and select column in async

ERD Sorry I'm just learning to use C#, How do I create a grouping function using async ? I want to add up the contract values, I tried with code like this public async Task <IEnumerable<...
3 votes
2 answers
15k views

SQL Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

I am using Microsoft.EntityFrameworkCore.SqlServer 2.2.6. I have a stored procedure which typically takes 1 to 2 seconds to execute. I am using .NET Core 2.2 with EF Core to execute that stored ...
  • 29.3k
0 votes
0 answers
230 views

How to "extend" EF data model in other assembly

I have solution with structure like this: Solution '-Project1 '-Model1.cs '-MainDataContext.cs '-Project2 '-Model1.cs '-MainDataContext.cs Project1 and Project2 are simple assemblies Project2 ...
  • 503
0 votes
1 answer
202 views

One to one relation between two abstract class in EF Core

I have a problem to create one to one relation for two abstract class. Each class has one table and discriminator. Classes are : public abstract class ValuationBase { public Guid Id { get; ...
1 vote
0 answers
52 views

EF Core 2.2 how to change/extend the default translation behavior for Oracle Data Provider

I am currently using EF Core 2.2 in my project which works with Oracle DB. I have a table in DB with a CLOB column. I have enabled Oracle Text search on this column. To perform Indexed search on this ...
  • 64
3 votes
2 answers
697 views

EF Core 5 Upgrade - Query Timeouts

We're belatedly upgrading a successful .net Core 2.1 MVC application to .net Core 5, and everything has gone well, apart from some confusing Microsoft.Data.SqlClient.SqlException 'Execution Timeout ...
  • 2,495
0 votes
1 answer
408 views

Why does HTTP PUT from Angular 9 service CREATE a new DB entity instead of UPDATING original? - cannot read property 'id' of null & concurrency error

I am new to Angular SPA and MVC in general, and I am currently working in Visual Studio 2017 on a MVC Core 2.2 Web Application project with EF Core ORM (the Model) and an Angular 9 front-end. The the ...
  • 167
0 votes
1 answer
197 views

Remove entity from joint table without affecting parent - EF Core 2.2

I have an issue with many-to-many relationship, and I do not understand why it is behaving this way: so I have the following: public class A { public Guid Guid { get; set; } public ...
  • 331
1 vote
1 answer
732 views

Using FirstOrDefault in a sub query

We are having major performance issues with some of our LINQ-to-SQL queries. We have a Case table, with a one-to-many relationship on CaseStatus (relationship table is CaseCaseStatus) Although, we ...
  • 678
0 votes
1 answer
110 views

npgsql connection pool repeated authentication

I'm using Npgsql.EntityFrameworkCore.PostgreSQL 2.1.2, EfCore 2.2, asp.net 3.1. Connection pooling is enabled (not passing it in the connection string). After enabling logging I'm getting logs like ...
  • 818
0 votes
1 answer
395 views

How to configure one-to-one relationship in EF Core with FK on both ends

I have following entities: public class Subscription { public int Id { get; set; } public int? BillingContractId { get; set; } public BillingContract BillingContract { get; set; } //...
0 votes
0 answers
258 views

EF Core 2.2 Enable SQL-Server Change Tracking

we use EF-Core 2.2 Code first approach to generate our Database. When the DB is created I would like to activate the Change Tracking feature of the SQL-Server. But I havent't found an option to send ...
0 votes
1 answer
338 views

How to handle divide by zero in Sum() with efcore

I'm struggling with an error affecting a system we used for Insights for our customers. The code is as follows: Insights MyInsights = new Insights(); MyInsights.UnpostedInvoiceValue = DatabaseContext....
3 votes
3 answers
6k views

Postegres ef-core update database produce "42P01: relation "__EFMigrationsHistory" does not exist" error

Setup Asp.NET core website 2.2 and EF Core 2.2 Postgresql database with multiple schemas and one of the schema already has __EFMigrationsHistory table when trying Add-Migration x1 -Context ...
0 votes
0 answers
238 views

Why is db context used after destroying in this LINQ query?

I have the following query and EF Core 2.2.6 public async Task<List<SamplePointContamination>> GetSamplePointsContaminationAsync(int siteId, int buildingId) { var ...
  • 139
1 vote
1 answer
479 views

EF Core Complex query gets cached for each variation of parameters

I have a complex query that seems to cause a memory leak in my applications memory. From my understanding the query result is cached so that this processing does not need to be done every time the ...
  • 2,861
0 votes
0 answers
274 views

EF Core pulling the same data twice

I have a function that sends e-mails to members of my system. Which e-mail they'll get, depends on different conditions. Lately I've discovered, that it sometimes sends to the same person twice. My ...
  • 361
1 vote
1 answer
159 views

dotnet ef core list never completes

After submitting a build though Azure Dev Ops, we noticed that the command to build the migration steps timed out after an hour of inactivity. It only happened on this branch and we've completed ...
1 vote
1 answer
414 views

Entity Framework Core 2.2 nested select generates multiple queries

I have a query similar to this: var customers = dbContext.Customers.Select(c => new { FirstName = c.FirstName, LoanStatuses = c.LoanRequests....
  • 1,553
2 votes
1 answer
915 views

How to access chained/nested property in EF Core 2.2

I have the following classes: public class Vehicle{ public Engine TurboV6 { get; set; } public class Engine{ public Cylinder Core { get; set; } public class Cylinder{ public double? ...
  • 565
1 vote
1 answer
48 views

Efcore 2.2- where clause runs after selection and returns false results

I have this simple query: Expression<Func<Tips, bool>> lastTipsPredicate = x => x.Status == (int)EnumGringo.LU_Status.active; IQueryable<Tips> lastQueryBase(DbSet<Tips> t) =...
  • 3,183
1 vote
1 answer
527 views

Why Angular app http requests hang after about 20 requests to different ASP.NET Core endpoints are made?

What is it Angular front-end app served via nginx on the server or cordova on android ASP.NET Core back-end, which connects to MySQL database via Pomelo connector. On production back-end app is ...
  • 327
0 votes
1 answer
145 views

EF Core 2.2.4 and seed data

I have the following code on DataContext: protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration<CollectionSite>(new ...
  • 8,241
1 vote
1 answer
90 views

EF generates a unwanted SQL for nullable entity

I have an entity that uses another entity that can be null class Parent { int? ChildId; Child Child; } class Child { decimal Property; } I am trying to do a filter of the child property but ...
  • 675
1 vote
2 answers
738 views

EF Core, nullable primary key results into inability to delete not-yet-added entity

I'm using EF Core 2.2.4. This is my entity: public class Person { public int? Id { get; set; } public string Name { get; set; } public string Surname { get; set; } } Notice that Person ...
  • 7,405
-1 votes
1 answer
1k views

How to Convert XML output from Stored Procedure to C# object in Asp Net Core

SET ANSI_NULLS ON; GO SET QUOTED_IDENTIFIER ON; GO ALTER PROC [dbo].[getStateWiseCompanyDetails] AS BEGIN With Data AS (SELECT Companies.RegionId, Companies.Code, ...
0 votes
0 answers
235 views

ef core shared child table with one-to-many

I would like to have a shared table that can be somehow referenced to multiple parent tables. The parent tables can have multiple rows from the shared Attachement table. The Type/TypeId would be a ...
  • 19
0 votes
0 answers
430 views

DateTimeOffset is not a supported primitive type or a valid entity type

I'm trying to create a timestamp with time zone in my postgres db. To do this, I'm using DateTimeOffset in my entity. When trying to create the table I get the following error: The property '[MyEntity]...
  • 1,420
0 votes
1 answer
63 views

Getting MySQL exception for old Column name missing

Im trying to pull a list of Runs objects where the details match the Platform field. Platform used to be called PlatformName. I've removed the old column name everywhere including the DB and code. For ...
0 votes
1 answer
91 views

Visual Studio forcing ASPNETCORE_ENVIRONMENT value

I am trying to use the Package Manager Console with EF Core 2.2 in Visual Studio 2019 to run an Update-Database command. I am targeting a specific database in my code by changing the connection string ...
  • 2,656
0 votes
1 answer
145 views

EFCore canConnect returning true for locked accounts

I am encountering odd behaviour with Microsoft.EntityFrameworkCore.Infrastructure DatabaseFacade.CanConnect() where this returns true even when a user account is locked, provided that the account has ...
1 vote
0 answers
136 views

Why does changing the OnDelete behaviour generates an empty migration?

I have a model in which I defined a one-to-one relation previously something like: modelBuilder.Entity<Parent>() .HasOne(parent => parent.Info) .WithOne(info => ...
  • 1,086
7 votes
0 answers
1k views

EF Core SQLite slow star-up performance on Xamarin

I faced with slow start-up experience of my Xamarin.Android application. The first DbContext creation takes ~4.5 seconds (context has 24 tables). At first I thought that the reason for this is that EF ...
  • 1,015
0 votes
1 answer
1k views

userManager.GetRolesAsync() returns list of roles but userManager.GetUsersInRoleAsync() returns empty list

Problem The below code fetches the roles of users but not the users in that particular role. Is there something missing? Code public void SeedRolesData(PartnerDbContext context) { if (!...
1 vote
0 answers
3k views

EF Core Fluent API Null Foreign Key

I have the following tables : Products, Users and ProductApproval. Whenever user create a new product, the ProductApproval will have a new record with the product ID and a null ApprovedByUserId ...
1 vote
1 answer
487 views

Can't see file created in the Xamarin.Android applicaiton

I figure out that my application creates the file but I can't see it in the files folder (e.g. by using X-plore). var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var ...
  • 1,015
-1 votes
1 answer
595 views

data migration takes long time

I have been written an c# console app for migrate data; count of records not so more; each table has almost 100 hundred records. but the structure of data and the businesses logic is so complicated ...
  • 371
1 vote
1 answer
73 views

Left outer join statements containing Reference navigation properties found in all split queries

I have an entity which contains several reference navigation properties under it. The Repository implementation for the entity looks some thing like this: return await _dbContext.MyEntity ...
  • 323
1 vote
1 answer
48 views

Translating Linq to SQL Update ... FROM Other_table WHERE

There is my expected result for EF Core translating UPDATE Table1 SET field1 = t2.field1, field2 = t2.field2 FROM Table2 as t2 WHERE t1.Id1 != t2.Id2 AND t1.Id2 = t2.Id2 AND t2....
1 vote
1 answer
41 views

Error while publishing an EF Core Angular app to Azure App service

One year back I have worked for a project using the EF Core Angular app (.NET Core 2.1). Now we got some modification to the existing application. So when I try to execute the same application by ...
  • 73
0 votes
0 answers
43 views

Eager Loading EF Core

I'm using EF Core 2.2 and have following schema: public class Person { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public ...
  • 13
1 vote
1 answer
2k views

Entity Framework Core throws SqlNullValueException when loading entities from DbContext

I have this MyEntity table in the database: The data inside MyEntity is the following: The EF Core entity is the following: public class MyEntity { public int Id { get; set; } public int ...
  • 1,544

1
2 3 4 5
12