Content
How to use EF Core when two properties in the Principle entity point to the same attribute in the dependent entity?
I have 2 Model classes: Department.cs cs public class Department { public string DepartmentId { get; set; } public string Name { get; set; } public string Description { get; set; } [ForeignKey("FacultyId")] public…


Stored Procedures returning null value in razor pages
Hi, i have two stored procedures which will execute based on the condition. First Stored Procedure : AvailableHourSlots CREATE PROCEDURE [dbo].[AvailableHourSlots] @ActivityName nvarchar(max) , @BookedDate datetime2(7) AS SELECT distinct…


EF Core 6 - Truncate Table
Hi, How can I use the truncate table in EF Core 6? I tried this but didn't delete rows. _oyunPalasContext.RazerReconciliation.FromSqlRaw("TRUNCATE TABLE RazerReconciliation");


Scaffold-DbContext probleme authentication integrated security
Hello I want scaffolding my azure sqserver database, but when i run this command : Scaffold-DbContext "Server=MydataBase.database.windows.net;Database=dev-base;Integrated security=true;Authentication=Active Directory Integratd;User…
Blazor Server IHttpContextAccessor returning null when deployed
I am dynamically setting the connection string based on the user that is logged in. This is working perfectly when running locally/debugging but when its deployed it's returning a null reference exception. This is my DbContext and I am handling the…


EF Core 6 - DateTime how to set null
Hi, I am trying to set null to a datetime field but unfortunately it is not setting null. public async Task UpdateOrderDetailAsync(OrderDetail orderDetail) { var detail = await…


ASP.NET Core Web API - DateTime Data Annotations Compare dates?
Hello, When the request is made, is there a way to compare with data annotations if the start date is smaller than the end date? Thank you. public class OrderHistoryRequestDto { [Required(ErrorMessage = "Please add…
ASP.NET Core Web API - DateTime Data Annotations Problem
Hello, I am trying to validate an API action method that has a start date and an end date. public class OrderHistoryRequestDto { [Required(ErrorMessage = "Please add StartDate to the request.")] …
What is the problem I have in my project
I SEE THIS ERROR my dbContext : using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Reflection.Metadata; using RepositoryPattern.Models; namespace RepositoryPattern.Data { …
EF core, apicontroller validation
Hi all Can someone tell me how validation works with ef core in a webapi controller? I have tried data annotations. They work, but I need additional validation. I tried making metadata classes but they just don’t seem to work. Is there a new…


When Extend IdentityUserRole and add migration it create the AspNetUserRole table again
Iam trying to extend the IdentityUserRole entity but when i add migration it recreating the AspNetUserRoles table with the foreign keys also my extend entity: public class ApplicationUserRole: IdentityUserRole<string> { public…


EntityFrameworks - scale out & replication
Hi all; I am writing a simple CRUD ASP.NET Core 6 app that will hit Azure SQL Database. Three questions on this: I will host the app in 3 datacenters for faster response & failover (via Front Door). In each of these datacenters the system…


Excludes an entity type from the model
Hello, could you help me please I have an existing project and I want to add integration tests to them, I chose the SQLite database provider, however some objects are causing problems while creating the database schema…
EF Core - List update with deleting not more present items
Good morning, to update a list of items I'm using this syntax, to verify if the item is present or not in the DB and so update or insert it as new item: foreach (MyList mylist in lstMyLists) { if(mylist.ItemId != 0) { …


how to save two tables linked by one to several simultaneously
for example Car and Simultaneous Image by first recovering the primary key of the car and assigning to the different images in a single Linq c# request


LINQ Expression Could not Be Translated
Hello everyone and thanks for the help in advance. I am creating a MVC application uisng .Net 6 and EF 6 to query a database. One of the functions is needed to search a date of birth. However, when I attempt to use the following: persons =…
EF6 Linq Navigation properties are always null
Here is the setup I have a product table public partial class Product { public uint Id {get; set;} public uint TypeId {get; set;} public virtual ProductType ProductTypeNavigation { get; set; } = null!; } public…


How to define foriegn key in my own classes.
Hi Folks, I am not sure if this is the right place to ask my question but it is somehow related to EF Core & Identity. I am using ASP.NET Core Identity in my project. I have added my own custom tables along with the tables created by Microsoft…


razor pages EF 6.0 insert data
While adding data to the database, Some people insert data directly this way : ... ApplicationDbContext.Add(MyModel); await ApplicationDbContext.SaveChangesAsync(); ... And some peoplpe add line by line the table field names : …


Visual Studio 2022 for mac, PM console or CLI to use entity framework command (add-migration, update-database, ecc.)
Hello, I'm using Visual Studio 2022 for mac, I have understood that the preview version not include PM console or CLI to use entity framework command. So, how can I do it? Which is the way to use entity framework commands, such as add-migration,…

