Microsoft Q&A

Entity Framework Core

420 questions

A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.

Browse all .NET tags

104 questions with Entity Framework Core tags

Sort by: Updated
1 answer One of the answers was accepted by the question author.

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…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2021-11-01T04:16:37.687+00:00
Uchchay Dugal 1 Reputation point
accepted 2023-01-29T15:05:43.83+00:00
Uchchay Dugal 1 Reputation point
1 answer One of the answers was accepted by the question author.

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…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2023-01-26T03:05:34.77+00:00
Blooming Developer 191 Reputation points
commented 2023-01-26T08:16:53.57+00:00
Blooming Developer 191 Reputation points
2 answers One of the answers was accepted by the question author.

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

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,923 questions
asked 2023-01-25T06:54:42.34+00:00
Cenk 666 Reputation points
answered 2023-01-25T11:22:57.64+00:00
Karen Payne MVP 29,226 Reputation points Microsoft MVP
2 answers One of the answers was accepted by the question author.

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…

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
8,474 questions
Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
12,583 questions
asked 2023-01-19T09:39:59.9066667+00:00
jimomo 20 Reputation points
accepted 2023-01-23T16:32:57.72+00:00
jimomo 20 Reputation points
1 answer One of the answers was accepted by the question author.

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…

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
783 questions
asked 2023-01-09T17:22:52.197+00:00
Richard Baker 21 Reputation points
commented 2023-01-10T07:15:20.983+00:00
Richard Baker 21 Reputation points
3 answers One of the answers was accepted by the question author.

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…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,923 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2023-01-02T17:50:14.69+00:00
Cenk 666 Reputation points
commented 2023-01-03T22:41:49.423+00:00
Arharbi, Adnane 131 Reputation points
1 answer One of the answers was accepted by the question author.

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…

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
asked 2022-12-30T13:53:53.96+00:00
Cenk 666 Reputation points
accepted 2023-01-01T05:05:51.573+00:00
Cenk 666 Reputation points
1 answer One of the answers was accepted by the question author.

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.")] …

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2022-12-29T17:25:13.087+00:00
Cenk 666 Reputation points
accepted 2022-12-30T13:50:05.017+00:00
Cenk 666 Reputation points
2 answers One of the answers was accepted by the question author.

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 { …

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
ASP.NET MVC
ASP.NET MVC
A Microsoft web application framework that implements the model-view-controller (MVC) design pattern.
582 questions
asked 2022-12-26T19:44:37.22+00:00
SparkCore 21 Reputation points
accepted 2022-12-28T18:56:10.963+00:00
SparkCore 21 Reputation points
1 answer One of the answers was accepted by the question author.

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…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,923 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2022-12-24T08:05:03.937+00:00
William Buchanan 61 Reputation points
accepted 2022-12-26T23:07:48.327+00:00
William Buchanan 61 Reputation points
2 answers One of the answers was accepted by the question author.

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…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
Microsoft Identity Manager
Microsoft Identity Manager
A family of Microsoft products that manage a user's digital identity using identity synchronization, certificate management, and user provisioning.
343 questions
asked 2022-12-22T14:03:01.62+00:00
Mohammad Arar (MiddleEast) 21 Reputation points
answered 2022-12-23T11:31:58.74+00:00
Mohammad Arar (MiddleEast) 21 Reputation points
2 answers One of the answers was accepted by the question author.

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…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
Azure Web Apps
Azure Web Apps
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,306 questions
Azure SQL Database
asked 2022-12-10T14:17:41.517+00:00
David Thielen 401 Reputation points
commented 2022-12-12T18:48:26.91+00:00
Alberto Morillo 24,631 Reputation points Microsoft MVP
1 answer One of the answers was accepted by the question author.

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…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,923 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2022-12-07T12:47:14.877+00:00
Andrej 141 Reputation points
accepted 2022-12-09T08:45:26.11+00:00
Andrej 141 Reputation points
2 answers One of the answers was accepted by the question author.

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) { …

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2022-12-06T11:19:20.207+00:00
Igor Baldacci 41 Reputation points
commented 2022-12-07T09:16:21.88+00:00
Igor Baldacci 41 Reputation points
1 answer One of the answers was accepted by the question author.

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

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,923 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2022-11-09T14:26:29.6+00:00
Nakashi Learn 21 Reputation points
commented 2022-11-14T08:22:34.507+00:00
Zhanglong Wu-MSFT 251 Reputation points Microsoft Employee
2 answers One of the answers was accepted by the question author.

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 =…

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
ASP.NET MVC
ASP.NET MVC
A Microsoft web application framework that implements the model-view-controller (MVC) design pattern.
582 questions
asked 2022-10-28T19:13:58.377+00:00
Kmcnet 201 Reputation points
commented 2022-11-01T19:56:52.457+00:00
Kmcnet 201 Reputation points
1 answer One of the answers was accepted by the question author.

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…

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2022-10-24T17:15:38.447+00:00
Jeff Vanhorn 21 Reputation points
accepted 2022-10-24T18:36:39.167+00:00
Jeff Vanhorn 21 Reputation points
1 answer One of the answers was accepted by the question author.

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…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2021-10-10T13:37:07.36+00:00
Imran Jalali 61 Reputation points
commented 2022-10-21T13:44:46.233+00:00
Wong Ke Ryn 1 Reputation point
1 answer One of the answers was accepted by the question author.

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 : …

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2022-10-11T10:08:41.333+00:00
Curious Cat 21 Reputation points
accepted 2022-10-11T13:11:01.54+00:00
Curious Cat 21 Reputation points
1 answer One of the answers was accepted by the question author.

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,…

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
601 questions
asked 2022-09-29T14:35:53.23+00:00
Igor Baldacci 41 Reputation points
commented 2022-10-05T14:15:28.077+00:00
Igor Baldacci 41 Reputation points