Questions tagged [ef-core-3.0]
Use this tag for version specific questions about the 3.0 version of Entity Framework for .NET Core. When using this tag also include the more generic [entity-framework-core] tag where possible.
404
questions
1
vote
1answer
42 views
LINQ-to-Objects - cannot group by Object
I upgraded efcore 2.2 to 5 and simple group by is not working,
the data is already in memory, take a look:
List<IGrouping<Categories, Businesses>> businessesByCategory =
location....
3
votes
1answer
70 views
How to run EFCore Migrate on ASP.NET start up WITH retries?
So I want to run EF migrations when the Azure app service is first started. The following code works correctly:
public class Program
{
public static void Main(string[] args)
{
...
...
0
votes
0answers
13 views
How to support data consistency in the database with EF Core?
am working on the web api application .net core 3.2. Database - postgre, ORM - ef core 3.1.4.
To understand the question I have to describe the business domain a bit. There are Alerts, Drawers, ...
0
votes
1answer
23 views
Why cant I add IsTsVectorExpressionIndex to modulebuilder for EF CORE using postgresql?
I am trying to set up full text search in a .net core 3-web app, using the instructions on NPGSQL website https://www.npgsql.org/efcore/mapping/full-text-search.html?tabs=pg12
In the OnModelCreating-...
1
vote
1answer
43 views
EF Core Postgres Update-Database is trying to Create Database which already exists
I am using PostgreSQL on EF Core in .NET Core 3.1. On my local machine, I was able to do Update-Database successfully, which created the database and applied migrations.
Now we are moving to a ...
1
vote
1answer
32 views
Is column a discriminator?
If a user does something like this inside OnModelCreating:
modelBuilder.Entity<MyBaseEntity>.HasDiscriminiator(x => x.EntityType)
Outside OnModelCreating, is it possible to either get the ...
0
votes
0answers
17 views
How To Soft Delete For Nested Entities & How Can I Understand My Class Inherited A Specific Generic Class Or Not
I have some nested entities to be soft deleted.
Here is Personnel:
public class Personnel : BaseIndelibleEntity<Guid>
{
public string Name { get; set; }
public string Surname { get; ...
0
votes
0answers
33 views
EF Core 3.0 not able to get data from Oracle DB view
I am not able retrieve data from Oracle View in using ORacle Entity Framework Core and .Net EF core 3.0, but tables are returning data.
The Context..ToList() is always showing 0 result with no errors.
...
0
votes
0answers
26 views
EF Core Power Tools does not keep identity column name
I have .NET Core 3.1 .NET Standard 2.0 class library with Microsoft.EntityFrameworkCore.SqlServer 3.1.8. I am using VS 2019 with EF Core Power Tools 2.4.217
All my SQL table names are pluralize and ...
0
votes
0answers
67 views
Data migration script for cosmos using EF core
I have a use case scenario, where I would like to load the data to a collection in cosmos using Entity Core Frame on project start-up
I am using SQL API for cosmos and EF core in the .NET application ...
0
votes
0answers
29 views
EF Core - Handling navigations when inserting a record through WebAPI
I've got following scenario in my web application.
I start creating a new table record. Therefore I access a server-side initialization logic via WebAPI. Once the initialization on the server has ...
0
votes
1answer
79 views
Dependency injection in DbCommandInterceptor
I am trying to add the Azure Redis Cache to my app. I am trying to do it with the interceptor, so when a query is done if the result is present in the cache I replace the result and I do one less ...
2
votes
0answers
486 views
EF Core 3.x Include query splitting without using tracking
When we migrated from ef core 2.x to 3.x, our queries slowed down and some of them are broken due to cartesian explosion problem. As you know, ef core 2.x was splitting query into several queries, ...
0
votes
0answers
24 views
Slow EF Core Performance when uploaded to Azure
I'm currently on EFCore 3.0. I have a query that fetch records from database that run within one second in localhost but more than 10 seconds when on Azure Web Service.
The code I written is to ...
0
votes
1answer
110 views
EF Core : How can I Create Geometry by Parsing Spatial Data
I had a requirement of storing static spatial data with some polygons, I imported GeoJson into my SQL Server to massage secondary data, once I had the correct data I exported my data into a Json (...
0
votes
0answers
19 views
Group Join And Order By Not Working Together
I am writing a query as below:
return await tbl1
.Join(tbl2,
ij => ij.LineId,
b => b.LineId,
(ij, b) => new { IJ = ij, B = b })
.Where(ijAndB =&...
0
votes
1answer
24 views
Insert SP in EF Core
I am using EF Core as my ORM. Ideally, I would use SaveChanges/ SaveChangesAsync to insert data into my DB, but there is a scenario where my table doesn't have a PK nor I can create it, not even a ...
1
vote
1answer
35 views
Execute SQL before each db operation using EF Core 3.0
I want to execute a sql script before each DB operation using EF Core 3.0.
One way to do the same is by subscribing StateChange event of DB Connection. Is there a better way to achieve the same ...
0
votes
1answer
24 views
Why isn't the TreeView showing the Children
I am writing a Program in .Net core (C#), which access a SQLite database using EF core.
namespace BtmManager.Models
{
public class Projekt
{
[Key]
public int ProjektId { set; ...
0
votes
0answers
26 views
When I add a related entity, the entity state is modified not added
Like Microsoft EFCore adding a related entity Demo, it works. But I Change the key type to Guid, after add entity to collection navigation property, the sub entity state will be Modified, why not ...
5
votes
1answer
44 views
Readonly table/entity EF Core 3.0
Is it possible to make a table/entity in EF Core 3.0? Basically i have history tables on which i want to ristrict insert/update/delete commands.
I already tried AsNoTracking by changing:
public DbSet&...
0
votes
1answer
44 views
Modify table dynamically in dbSet
I am using EF Core 3.0 and have a requirement to change table name dynamically for which I am thinking to create an extensiion method.
Exact requirement:
I have two tables 'Sample' & '...
0
votes
1answer
76 views
EF Core query to get all records with a date column greater than server date
I have a requirement to get all the records from my MySQL table by comparing a column in my table (datetime type) to be greater than the MySQL server time.
My MySQL query is like this
string ...
0
votes
0answers
18 views
EF Core 3.0 : Is it possible to define a dependent entity with two principal entities?
I have a typical scenario where I have a class which is referred from two different classes.
At any point in time, a dependent class can have only one principal class reference.
class P1{ //Principal ...
0
votes
1answer
66 views
EF Core 3.0 : Multiple navigation properties in an entity
Here are the 2 entities I have defined and I am using EF Core 3.0.
Whenever I try to create a new migration, I keep getting an error saying can not have the same navigation property in multiple ...
0
votes
1answer
42 views
EF Core 3.1 - Sql server IN operator translation (without AsEnumerable()/ToList())
I have just done the upgrade from EF Core 2.2 to EF Core 3.1. I have some queries like this:
...
userIdList.All(u => _context.ConversationUsers.Count(x => x.ContextOwnerCode == t....
0
votes
1answer
85 views
ModelState is invalid for a nullable property
I have a model where the property CompanyID allows a null value
public partial class ReportTemplateItem
{
[Key]
public int ReportTemplateItemID { get; set; }
[Required]
public int ...
0
votes
0answers
46 views
FooProof Core validating in Asp.NET Core for Validation but shows exception
I am using FoolProof COre in Asp.Net Core 3.0 Application.
My Model is
public class PaymentReceiveMVm
{
public int PayMode { get; set; }
public string PaymentMode { get; ...
0
votes
1answer
344 views
How to configure One to One relationship in EF Core without Foreign Key? [duplicate]
This is what I've tried.
class ReferralRegistrationConfiguration : IEntityTypeConfiguration<ReferralRegistration>
{
public void Configure(EntityTypeBuilder<ReferralRegistration> ...
2
votes
1answer
94 views
One to many relationship LINQ update query
I've a one-to-many / many-to-many relationship b/w UserProfile & AddressMaster through intermediate table UserAddress.
public class UserProfile
{
public string UserID { get; set; }
...
0
votes
2answers
54 views
One to many in Ef core Fk Viloation
Ok I think I may have got this wrong in the model builder. I want the case which can be one case but inside that one case they can be many relationships.
modelBuilder.Entity<RelationShips>()
...
0
votes
1answer
44 views
Any alternative to hidden fields when updating from a viewmodel? I don't want to have all fields in the edit page
I know there is a way to do this the "right" way, but for some reason I can't find an answer. I even saw on Microsofts guide that hidden fields are the way to go, but it feels "wrong&...
0
votes
0answers
23 views
Handling temporary creation of foreign key table values
I have a foreign table in my context called relationships each case can have many relationships. However I don't want to hit the final save until they have saved their full relationship until they ...
1
vote
0answers
84 views
How To Improve SQL Query Speed from 4 seconds to maximum 500 ms in Net Core 3.1 in a filtering situation, SQL Server Enterprise 2019, Windows Azure
We need to improve some queries into a Real Estate Project ~ similar with booking.com where we need to do some filtering to Products . Filters Will be in left Side , products in the right.
Filter ...
0
votes
2answers
418 views
EF Core without additional repository pattern
There seems to be a certain movement advocating that when we use EF Core we should avoid creating a Repository & Unit of work pattern because EF Core already implement those two and we can ...
0
votes
0answers
24 views
Logging Entity Framework Core With existing LoggerFactory
I'm trying to log SQL queries executed by ef core. As I've configured the logging on CreateHostBuilder when the Host is created, I want to use the LoggerFactory finally created to log the executions ...
0
votes
0answers
408 views
The entity type T requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()'
I have just done the upgrade from EF Core 2.2 to EF Core 3.1. After this I am experiencing this error.
I have defined this class:
public class AdminCompanies
{
public int Code { get; set; }
...
0
votes
0answers
45 views
How can I add custom operators to Entity Framework Core 3.0?
I'm using EF Core 3.0
While I am able to map custom SQL Server Functions (things like CHARINDEX('t','customer')) using the
[DbFunction] attribute, and defining translation in the ...
0
votes
2answers
53 views
When i want don't modified one Attributes,It's not work,question for ef core
I don't Want Modified UserPassword when it's null or empty ,I search for long time but it's doesn't work
Would you give me some advice ?
public async Task<IActionResult> Edit(int ID, [Bind("...
1
vote
1answer
357 views
.NET Core console application with EF Core is not working when run from using dotnet run command, throwing authentication failed exception
I wrote a simple .NET Core console application to explore EF Core using the code first approach and I followed the below steps (windows machine).
Create a new .NET Core console application
dotnet ...
0
votes
2answers
97 views
Mocking DbContext with NSubstitute and Repository is empty or NotImplementedException
I'm trying to mock my DbContext class to do unit tests with NSubstitute but I cannot recover this data from my fake dbcontext through the repository class.
I have a generic class (SubstituteDbContext) ...
1
vote
0answers
167 views
ASP.NET Core 3.1 - EF Core can't translate GroupBy and Join
I recently updated my web application and I regret all my most complex requests no longer weigh. I saw that a lot of people had this problem but I don't quite understand how to solve them. I know that ...
1
vote
1answer
309 views
Where to call EF Core Migrate in web API startup class?
I'm trying to process DB migrations during application startup in a Azure-hosted web API. However, no matter where I try to put it, I get the exception:
ObjectDisposedException: Cannot access a ...
0
votes
1answer
44 views
What is the best approach to update child table when updating parent table?
Net core Ef Core. I have two tables, Schema looks like below.
Student table - StudentId Name Class, IsActive
Address Table - AddressId, City, Country, IsActive, StudentId
Idea is when I update ...
0
votes
1answer
42 views
Is it a bad idea to make ef core DbContext transient?
I have multiple IHostedService instances and each instance according to the time when it springs to action should use DbContext to perform some database works.
Should I use scoped, transient or ...
0
votes
1answer
140 views
MongoDB using DDD coming from RDBMS World advice
I am writting an application and it was all going well using RDBMS, but I could know that what I was doing was a candidate for a NoSql database.
I am prototyping an app where you swipe persons and you ...
0
votes
0answers
25 views
Optional column in DB Set EF Core 3
I have about 10 procs returning the same columns which I am binding to a DbSet model. Now due to a business requirement, one of them will be returning one additional column. I tried to add that ...
0
votes
1answer
256 views
Dot Net core- Generate code for entity issue
I have a project include two project in same Solution Explorer
First: DbModelContextProvider (Class library)
Second: AppApiProvider (MVC core api -v3.1.4)
I want create a controller API Controller ...
0
votes
2answers
46 views
EF Core cannot achieve OR translation dynamically by IQueryable.Where
using (var ctx = new StockContext())
{
var syms = new string[] { "foo", "bar" };
return ctx.Assets.Select(x => x.Symbol)
.Where(symbol => syms.Any(sym => ...
1
vote
1answer
71 views
Entity Framework error : “Navigation properties can only participate in a single relationship”
I am having setup similar to below
public class Component
{
public int Id { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public List<ComponentUpdate&...