Content
EF Core query for a specific condition in related entities and update parent entity
Hello there, In my Blazor Server application, I have Order and Order Details entities which are related as you can imagine. They both have their own repositories. public class Order { public int Id { get; set; } [Required] …
EF Core 6 - Adding records based on a condition
Hi friends, In my Blazor server application, I am inserting BulkPurchaseRequest records into DB as follows. public class BulkPurchaseRequestsRepository : IBulkPurchaseRequestsRepository { private readonly OyunPalasContext _oyunPalasContext; …
4.6.1 migrating to .Net Core 7 – How do I resolve error MC1000- cannot find type System.Management.Instrumentation.InstrumentedAttribute in Assembly ..path \.nuget\packages\system.management\7.0.0\lib\net6.0\SystemManagement.dll – Microsoft.WinFx.Targets
I am migrating a .netFramework 4.6.1 application to core. I have been able to get rid of all of the build errors except this one: Error MC1000 Unknown build error, 'Could not find type 'System.Management.Instrumentation.InstrumentedAttribute' in…


I can't use class on layered architecture
I'm working on a web.api for library otomation project. I'm using layered architecture on project. a485553e-89a6-4fa9-8dd5-1c40de6d40e2.jpg image is my architecture. I couldn't access User.cs class on DataAccess layer. I defined with "usign"…


EF Core - Getting records randomly based on a certain criteria
Hi there, I would like to get data one by one (TOP 1) where all the statuses of all related BulkID = 1 randomly. Here is what I tried but didn't work as I wanted. Select TOP 1 BulkId, ProductCode from BulkPurchases where status = 1 group by…
Deserialising a Json string throwing error in razor pages.
Hi , I have a jsonresult like shown below "{\r\n "AccessRights": [],\r\n "ADAttributes": [\r\n {\r\n \ "AD": "teenajohn",\r\n \ "ADFull": "",\r\n …


Entity Framework 框架问题
dbcontext不同的实例,savechanges被互相影响怎么回事


EF Core 6 Adding a table manually?
Hello friends, I am working on a web API project that I implemented with the code-first approach. I wonder if there is a problem creating tables manually without using migrations. Does it cause any problems? Thank you.
Executing Stored Procedures based on condition in Razor Pages
Hi, I have a function that executes two stored procedures based on a condition. Stored procedure for the first condition works fine, but stored procedure for the second condition fails. public async Task<JsonResult>…


JSON Format WebAPI Entity Framework
Currently the JSON I'm using looks like this: The JSON file is huge so I'm only showing the first few rows in the file so not all data is shown. I'd like to get this JSON structured so I can use in a TreeView menu so I'd like to see get the out put to…


Duplicate primary key name when running Update-Database
I am using EF Core 7, with LIve Migrations enable in a code first project. I have a model using TPT strategy. When I generate the model, it gives me the error: Failed executing DbCommand (10ms) [Parameters=[], CommandType='Text',…


EF Core 7 - System.InvalidOperationException
Hi, Can someone please help? I am trying to insert a record with an FK using DBContext. EF Core keeps saying that the Country is already tracked. I am aware that EF Core thinks that I am inserting a new country but that's not my intention. In the below…


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…


Inject EntityFramework DbContext in a .NET 6 Azure Function
Where do I have to put the DbContext in a .NET 6 Azure Function? builder.Services.AddDbContext<DataContext>(options => // options.UseSqlServer(context.Configuration.GetConnectionString("BlazorOrderApp"))); There is…


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");


Blazor Server - System.InvalidCastException: Unable to cast object of type 'System.Double' to type 'System.Single'.
Hi, In my Blazor server application, I am trying to get the records from RazerReconciliation table as follows. I couldn't figure out why I am getting this error. public async Task<List<RazerReconciliations>> GetOldReconsAsync() { var…
Bilgisayarıma .net 7.0 kurdum fakat powershell üzerinden dotnet tool install --global dotnet-ef komutu kullandığım zaman kurulu değil hatası alıyorum yardımcı olur musunuz
Visual Studio 2019 kullanıyorum ancak bu kurulumu yapamadım yardımcı olursanız sevinirim


Entity Framework Core can't create migrations table using created login
I am doing a some training with .Net 6.0, C# and Entity Framework Core. I got to the point that EF can generate a new migration but hen I run dotnet ef database update I am getting an error: Failed executing DbCommand (38ms) [Parameters=[],…
SQLAzure is not available for your selection of subscription and location
Hi Folks, Trying to use Azure for the first time, I'm using a normal account (i.e not free tier or student) but it is just for a hobby project. I'm following the tutorial here in order to deploy my EFCore webapi…

