All Questions
Tagged with entity-framework-core asp.net
944
questions
0
votes
0
answers
46
views
.Net Core 8 Entity Framework (MySQL) DROP PROCEDURE IF EXISTS `MYSQL_BEFORE_DROP_PRIMARY_KEY` Error
I'm created a migration to add a few tables and update one table (add one column). The database is MySQL 8.0.31 and the EF provider is Oracle's MySql.EntityFrameworkCore
The migration was completed ...
-1
votes
1
answer
65
views
Cannot add multiple same objects to DB, only distinct are saved. .NET EntityFramework
I have a template of exercise with name, description and amount of sets. I want to create multiple objects of Exercise * amount of sets. For example I have template [{ "name" : "Legs&...
1
vote
0
answers
43
views
How do I abstract ASP.NET Identity in Clean Architecture so that entities in Domain layer can reference Identity user for relationship mapping
public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationUserRole, string>, IApplicationDbContext
{
public DbSet<ChatEntity> Chats { get; set; }
public ...
-1
votes
2
answers
57
views
How to update only fields present in a form for a model in EF Core?
To simplify the problem, in C# I have a model like this
public class Person
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Key]
[MaxLength(128)]
public string? Id { get; set; ...
0
votes
1
answer
81
views
Complex queries in Entity Framework Core
I have these two entities in EF Core:
public class Chat
{
public int Id { get; set; }
public string SessionId { set; get; } = string.Empty; // Could be sessionId or anything that indicate the ...
0
votes
0
answers
76
views
How can I dynamically add select items in a LINQ query?
I have this:
IQueryable<ScreenerData> query = _context.ScreenerData;
which is financial metrics I have made a screener which filters out items. But I want to return some fixed data which doesn'...
0
votes
1
answer
94
views
Entity Framework Core problem: error within getting record: Unable to cast object of type
I have a problem that when I call multiple repository types in one class in one scope, I get an error:
System.InvalidCastException HResult=0x80004002 Message=Unable to cast object of type '...
0
votes
0
answers
44
views
Entity Framework Core with Npgsql: Duplicate key value violates unique constraint "PK_Posts"
I'm encountering an issue while trying to save a new PostEntity to my PostgreSQL database using Entity Framework Core with Npgsql. The error message indicates a violation of the unique constraint on ...
0
votes
1
answer
21
views
How to reload the Create view after AJAX Post?
I have two Model Classes, Telephone and Telephone Model.
To create a new Telephone it is necessary to choose a TelephoneModel.
I want to add within the Telephone Create View, a Modal to create a ...
0
votes
1
answer
59
views
dotnet-ef : The term 'dotnet-ef' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
Below error in dotnet core 8 can be solve by following below steps:
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ dotnet-ef
+ ~~~~~~~~~
+ ...
0
votes
3
answers
135
views
Invalid LINQ Expression ... could not be translated
I don't know why, when I execute this LINQ request, this exception is returned :
System.InvalidOperationException: The LINQ expression '__ids_0
.Contains(StructuralTypeShaperExpression:
Patron....
0
votes
1
answer
77
views
Entity Framework query throws System.NullReferenceException when executing
I'm trying to execute this method:
public async Task<List<JobDetail>?> GetJobDetailsByJobIdAsync(int JobId)
{
using ApplicationDbContext context = await _factory.CreateDbContextAsync();...
0
votes
0
answers
21
views
complex migrations with moving data
I have asp .net core application. I would like to split table with data into the more parts and migrate some data from one table into the new one. Is there a way how to do that?
Before:
table_a
-------...
0
votes
0
answers
35
views
Extending ApplicationUser on a fresh Blazor Server-only project with Individual accounts
I'm trying to extend ApplicationUser with custom properties on a fresh Blazor server project. Here's what I have:
public class Tariff
{
public int Id { get; set; }
public required string Name {...
0
votes
1
answer
56
views
Collection is read-only Exception with EfCore Include method
I am encoutering error
System.NotSupportedException: Collection is read-only
when selecting Film aggregate from sql server with EfCore like this:
var film = await dbContext.Films
.Include(f =&...