Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
140 views

I have a generic ASP.NET Core Web API that uses EF Core to connect to a SQL Server instance that uses Microsoft Entra MFA account. The connectivity prompt for the SQL Server looks like this: I have ...
James's user avatar
  • 1,345
0 votes
1 answer
106 views

I am trying to define two classes with the same collection-relation, through the same key on a third class, preferably using EF 6 code annotations. I have three tables; Current is a quick reference. ...
Joachim J's user avatar
  • 204
0 votes
2 answers
66 views

I have a class for users : public class users { public int UserId { get; set; } public string UserName { get; set; } // .... } I want to create a table called users. I write this line in ...
Hosein Ghasemi's user avatar
0 votes
0 answers
65 views

I know there are a ton of QAs on this topic but none of the answers I've looked at have helped me. I'm sure it's something simple. I am in the process of moving from database-first to code-first using ...
Ego Placebo's user avatar
0 votes
0 answers
28 views

I have an Entity Framework 6 (v6.5.1) code-first model like this (type names have been changed to anonymise the code): public abstract class Point { public long ID { get; set; } public long ...
Hydrargyrum's user avatar
  • 3,876
0 votes
1 answer
78 views

How do I display the Sum records of a child property in a field in the parent model? for example Order Model: public class Order { [Key] public int Id { get; set; } public string Title ...
AliRam's user avatar
  • 80
1 vote
1 answer
200 views

I'm working with Entity Framework Core and encountering the following error: Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException Attempted to update or delete an entity that does not exist in ...
LemonPotion's user avatar
0 votes
1 answer
56 views

I'm writing a server for a client that I do not control. I'm using HasData to seed the database with static information that the client refers to by ID. The client uses 1-based numbering for almost ...
Kevin Krumwiede's user avatar
0 votes
1 answer
53 views

I have an Entity Framework Core model defined as follows: class User { public int ID; public ICollection<Foo> OwnedFoos; } [PrimaryKey(nameof(ID), nameof(OwnerID))] class Foo { ...
Mike Burton's user avatar
  • 3,020
0 votes
0 answers
60 views

I have seen countless posts advising that EF Core with SQL Server blocks multiple foreign keys which have "OnDelete Cascade" (due to cycles and multiple delete paths). However I see in the ...
victorswhisky's user avatar
1 vote
1 answer
176 views

I'm building an Entity Framework Core web project using code first migrations and when I update the data via update method, I get the following error message: Violation of PRIMARY KEY constraint '...
Dave Koppe's user avatar
0 votes
0 answers
23 views

I have been trying to use code first approach to create a database via already written models and context class. Below is my context class for reference. using BankLibrary.Models; using Microsoft....
RAHUL GIRI's user avatar
0 votes
1 answer
216 views

I have created two projects in ASP.NET Core 8: 1. Web API project which contains Connection string in appsettings.json DbContext registration along with connection string in Program.cs file 2. Class ...
Digvijay Singh's user avatar
0 votes
1 answer
1k views

I'm using EF Core (8.x) and Posgresql for storing some data. Specifically, I have an entity type which has a (navigation) property holding an entire object graph, that I have specified in ...
Mark's user avatar
  • 11.8k
0 votes
1 answer
66 views

I have a mapping application that will display pins on a map that represent Features at Member addresses (e.g. a Member lives at lat/long 'X' and is associated to Feature 'Y'). Members can be ...
Bob H's user avatar
  • 51
0 votes
1 answer
131 views

i am working on a Winui/c# app with EF core and sqlite db. i am searching in a db with multiple tables every tables contains 9M records (9,000,000). for this heavy search i used Task.Run and async/...
Chibako's user avatar
  • 69
0 votes
1 answer
94 views

I have a model in my Blazor app that I want to create a "transitory" attribute for. This attribute is used internally in the app, but I do not want to persist it to the database. However, ...
user101289's user avatar
  • 10.5k
1 vote
1 answer
38 views

I have two entities with this structure: public abstract class BaseEntity { public BaseEntity() { //Validate(); } public Guid Id { get; set; } = Guid.NewGuid(); public ...
Navid_pdp11's user avatar
  • 4,128
0 votes
0 answers
129 views

Assume a class like this: public class Book { [Key] public Guid Id { get; set; } public string ISBN { get; set; } = default!; public string Name { get; set; } = default!; public ...
kbd's user avatar
  • 4,539
2 votes
1 answer
499 views

Background I have a table model like this: public class Book { [Key] public Guid Id { get; set; } public string Name { get; set; } = default!; public string Author { get; set; } = ...
kbd's user avatar
  • 4,539
0 votes
1 answer
619 views

I am working on a .NET 7 project with EF Core 8 and attempting to use code first migrations with Microsoft SQL Server, but for some reason I can't get any default values to generate in the migrations. ...
Kevin's user avatar
  • 192
1 vote
1 answer
2k views

I am trying to create migration using Add-Migration InitialMigrations in my Asp.net Core 8 Web API project, but I am getting the following error: Unable to create a 'DbContext' of type 'AMSContext'. ...
Waleed Umer's user avatar
0 votes
0 answers
56 views

I'm seeding the User identity table using EF core configurations, this is my method. public void Configure(EntityTypeBuilder<IdentityUser> builder) { var hasher = new PasswordHasher<...
Sgri's user avatar
  • 3
0 votes
1 answer
35 views

I am developing a database using c# with Entity Framework 7.0 Code First. I have come across a scenario that's a little tricky for me. Consider the following entity diagram. A Store has many Pods A ...
Kieran's user avatar
  • 316
1 vote
2 answers
2k views

I am working on a .NET 8 project using C# and Entity Framework Core. I am trying to add a navigation property in my data model to create a connection in the tables. I followed the documentation from ...
CyberDeveloper's user avatar
0 votes
1 answer
99 views

I want to make a MSSQL using code-first approach. I have defined two models - Product and Category and then defined the DbContext as you can see below: public class ApplicationDbContext : DbContext { ...
JustSoni's user avatar
0 votes
0 answers
169 views

I have configured the updatedAt property as shown below. I expected that the updatedAt value of the corresponding row alone will change when inserting or updating. But when tried this it is updating ...
Learner's user avatar
  • 55
0 votes
0 answers
59 views

I've inherited a non-complete clean solution from the point of view of CodeFist on a .NET 7 project. The scenario is the following: I had an old part of the Codebase that used EF Code first migration ...
advapi's user avatar
  • 3,967
0 votes
1 answer
358 views

In Entity Framework Core, how can I access the Entity Type data (the entity names, regular properties, navigation properties, etc.) when using code-first? When using database-first, I can use ...
John Cummings's user avatar
0 votes
1 answer
58 views

I have Three Table ApplicationUser, Posts, Comments there is a one to many between users and Posts there is a one to many between Posts and Comments these Relations Has CasCade Delete and working ...
Hossam Elsayed's user avatar
0 votes
1 answer
498 views

I have 6 entities in total but my issue is with these following 3: Departement, Filier and Etudiant. The Departement entity contains many Filiere and many Etudiant entities, while Filiere and Etudiant ...
sami kechiche's user avatar
2 votes
2 answers
2k views

I'm in .net8 ef core with postgres database and code first approach. I have these two class: public class Soggetto { public long Id { get; set; } public virtual Azienda ...
Tox's user avatar
  • 43
0 votes
1 answer
54 views

Refer to my code example below where I'm trying to implement a code-first connection to a SQLite database. I am working in .NET 4.8 (not Core). All the column names and database table names are ...
Henry's user avatar
  • 3
0 votes
0 answers
75 views

I have a patient class which has navigation property PatientGroupMemberships, and PatientGroupMembership had PatientGroup property, and PatientGroup has property Name. I want to sort by Patient's ...
Manoj Soma's user avatar
2 votes
0 answers
121 views

I have a question about Entity Framework. I use the Code First approach. Let's say I have several classes representing a table in a database. I use navigational properties and in some places the IDE ...
cinosz's user avatar
  • 23
0 votes
0 answers
219 views

My app has an abstract base/parent class (Contact), and concrete child classes (Phone, Email) inheriting from the base, and other classes referenced from the base - I left Person and Notes for the ...
Mykola's user avatar
  • 236
0 votes
0 answers
72 views

I have a Domain model below that needs two domain services to check the database state and generate the date time now for the sake of testability: public class Person { public string Name { get; ...
Navid_pdp11's user avatar
  • 4,128
0 votes
0 answers
28 views

I have an entity business owner given below. It is recursive entity with ParentBusinessOwner property. public class BusinessOwner : ISystemOperated, ICachable { [Key] public int ...
LojiSmith's user avatar
  • 300
0 votes
1 answer
108 views

I am using code-first approach in EF, I have created a stored procedure to select, and when I run it, I get the value from User table but the FK attributes are null. This is my stored procedure: ALTER ...
M Faizan Raza's user avatar
0 votes
1 answer
243 views

I am trying an experiment to switch from a one-to-many that will always have 2 in the list, and have 2x one-to-one relations using composite keys. Modeled classes: public class Game { [Key] ...
Ginger Ninja's user avatar
0 votes
0 answers
53 views

I am trying to update an entity named SaleLedger with some relationships in it. But while calling Context.SaveChanges() it throws an exception I am using EF 6.4.4 and SQL Server database My Entity is ...
Aamir Ehsan's user avatar
0 votes
0 answers
58 views

I'm trying to do my first API with ASP.NET Core 6 and Entity Framework Core. Basically I have a model class: namespace SistemaDeTarefas.Models { public class UsuarioModel { public int ...
Ricardo Zancan da Costa's user avatar
0 votes
1 answer
35 views

I need to use the system version property and the table history of the SQL in the code-first method, so that one, by using a token, when a record was changed between selection and editing, it gives an ...
emad.b's user avatar
  • 13
0 votes
1 answer
57 views

I'm using GraphDiff library in my c# project to update a disconnected graph. My Document entity has a one-to-many relationship with DocumentRelationShip entity as ToDocumentRelationship navigation ...
Masoud's user avatar
  • 8,246
12 votes
2 answers
9k views

I have an ASP.NET Core project which uses code-first in EF Core. After upgrading from .NET 7 to .NET 8 and also EF Core packages I'm faced with an error SqlException: Incorrect syntax near '$'. This ...
Arash.Zandi's user avatar
  • 1,717
1 vote
2 answers
100 views

My problem is I get this error The entity type 'List' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on ...
dancho's user avatar
  • 111
0 votes
1 answer
207 views

First of all it needs to be clear that I never worked on a project that uses code first, and I inherited this project from another developer. Right now I am trying to reproduce the error to post here ...
Gustavo Heck's user avatar
1 vote
1 answer
168 views

Almost all exceptions are getting caught except the exception from EF core . The exception filter is catching any error . but not errors from entity framework. If you need any other info like efcore ...
saronyo bose's user avatar
0 votes
0 answers
50 views

I have a requirements where we are supposed to store all the key-value in one table. For example, status of application, status of user requests, status of incident etc. We don't want to create ...
TechTurtle's user avatar
  • 3,267
0 votes
1 answer
882 views

I want to use DbContext variable inside the Migration Up method. I explain better my problem: I have one migration done in this way class Circle { public int Id {get; set;} public int Radius {...
Federico Ruocco's user avatar

1
2 3 4 5
171