Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
123 views

I have these model classes (deleted not related parts): internal class RelationTypeModel { public Guid Id { get; init; } public required string Name { get; init; } public class ...
Sarrus's user avatar
  • 673
0 votes
1 answer
78 views

I have this model class: internal abstract class GraphNodeModel { public Guid Id { get; } public Guid TypeId { get; } public virtual GraphNodeTypeModel? Type { get; } public List<...
Sarrus's user avatar
  • 673
1 vote
1 answer
69 views

I have works, users and likes. A like is a connection between a user and a work. The work was created by a user. I would like to have tables like this: public class DbUser { public Guid Id { get; ...
Pavel Kostin's user avatar
0 votes
0 answers
62 views

I am working on a console application in order to practice my skills. I've connected to my SQL Server database, created the tables and seeded the data using code first approach. Now I am trying to use ...
Raducu Mihai's user avatar
0 votes
1 answer
66 views

I'm trying to create a one-to-many mapping using EF Core Fluent API. I have these 3 tables: User Role User Role Mapping Table These C# classes represent these tables: public class User { public ...
Varanasi Phaneendra's user avatar
0 votes
1 answer
79 views

A one-to-one relationship is defined between 2 entities in 2 different ways, but only the one using generic methods is working. The configurations are done on the DomainVerification entity. Given the ...
Nandor Krizbai's user avatar
0 votes
1 answer
91 views

I have 2 tables Company (Id uniqueidentifier, ...) and Address (Id int, ...) and representative entities Company and Address. They should have a one-to-one relationship. As I don't want to have any ...
demo's user avatar
  • 6,295
0 votes
0 answers
84 views

I'm overriding the IdentityRole / IdentityClaim, etc. However, I've noticed that some of these fields has no effect either in Fluent API or via attributes. Class that overrides IdentityRole<Guid>...
Deukalion's user avatar
  • 2,675
2 votes
1 answer
352 views

This might be a duplicate but sincerely I have spent sleepless nights trying to figure out how to implement this relationship. Basically, a bank customer can have many accounts that they are primary ...
Seyi Agboola's user avatar
0 votes
0 answers
54 views

I have inherited some code which is now causing an issue w. The code looks similar to the following (albeit redacted). public class ObjectX { public Guid Id { get; set; } public List<ObjectY&...
Alan Rutter's user avatar
0 votes
1 answer
273 views

I am trying to configure a field in model which is to be modified with insert and update. I tried multiple things but still could find the correct configuration for my requirement. Example : public ...
Learner's user avatar
  • 55
0 votes
1 answer
36 views

I have 2 classes and I want to avoid using navigational properties. So instead of: public class A { public int Id { get; private set; } public B B { get; private set; } } public class B { ...
Yoda's user avatar
  • 18.2k
1 vote
1 answer
640 views

A little bit of preface: I am working in EF Core 6 and was trying to create an SQL query using the Fluent API. The raw SQL query that I am trying to achieve is: SELECT * FROM [table] AS [t] LEFT JOIN [...
TheCaeserSalad's user avatar
0 votes
1 answer
149 views

Original Question I have the following entity I’m trying to get to work with EF Core/NET7, where two properties map to the same column. This way either property could be used in various interfaces ...
Aaron's user avatar
  • 53
2 votes
1 answer
290 views

I have a table bills and a table documents. A bill can be related with many documents and a document can be related with many bills. A many to many relationship. Also, in the join table, a have a ...
Álvaro García's user avatar
1 vote
1 answer
500 views

The Entity Framework Core version is 7.0.10. While getting data from database, it throws out no primary key exception even I have already set it up in model class. The entity type 'Order' requires a ...
Robin Sun's user avatar
  • 1,670
1 vote
0 answers
149 views

I've seen similar questions and have tried applying the answers, but to no avail, so I wanted to ask my question with more context of what I've tried. My property looks like this: [Column("colnm&...
Jason Jacobs's user avatar
1 vote
1 answer
274 views

I have two entities CodeMaster and Employee. In Employee, I have more foreign key optional properties to navigate to the CodeMaster entity. When I insert data into Employee, I get this error: Inner ...
Ahasanul Banna's user avatar
0 votes
1 answer
308 views

I have this setup (roughly, I've edited out the irrelevant code for readability). public class LevelSection { public Guid Id { get; set; } public Guid UserDataId { get; set; } } and then ...
markovic-m's user avatar
0 votes
0 answers
57 views

I am having trouble trying to link an object to a list of Addresses using a middle table that is uses a different table's primary key with the primary key for Address. I want a one-to-many one-way ...
coxie's user avatar
  • 1
2 votes
0 answers
21 views

First I will expose the code that reproduces the problem. Then I will explain the problem. I have two entities, Employee and ContactForm (address, email, telephone...): public class Employee { ...
Álvaro García's user avatar
1 vote
0 answers
99 views

I have these 3 Value Object (LanguageId, AttributeSetId and AttributeSetTranslationId public record LanguageId(string LangCode); public record AttributeSetId(Guid Value); public record ...
Beach's user avatar
  • 11
0 votes
0 answers
83 views

I'm using EntityFrameworkCore 7.0 in conjunction with Pomelo.EntityFrameworkCore.MySql to build a Code-First app relying on MySQL. I'm using the Fluent Api and IEntityTypeConfiguration<> ...
Jean-Louis Arnal's user avatar
0 votes
1 answer
628 views

This is my first question on the website, so if something seems off or the syntax isn't quite right, please let me know! The schema below allows a player to join a profile using the many-to-many table ...
Claw's user avatar
  • 21
0 votes
3 answers
127 views

I want to create a direct relation between the Task entity and the child entities, to get with the task the corresponding child and when I get the child to get the corresponding task. I have an entity ...
Florin's user avatar
  • 41
0 votes
1 answer
148 views

I created a model called ProductCategory (image #1) and configured this class using the Fluent API method (image #2), but unfortunately when I create Migration, all the configurations including the ...
Ali.Ghorbani's user avatar
0 votes
1 answer
373 views

I have been with this issue for some time now, and I have not seen a solution in either Microsoft's docs or on StackOverflow. The issue: I have an abstract class, Workout: public abstract class ...
Davrozz's user avatar
  • 57
0 votes
0 answers
154 views

Let's say I have two entities/model class AccountModel: public class AccountModel { [Key] public int AccountSk { get; set; } [ForeignKey("Region")] ...
RadahnsHorse's user avatar
1 vote
1 answer
267 views

I am trying to setup a specific relationship using FluentAPI on 2 entities. See details below public abstract class Entity { [Key] public int Id { get; set; } } public class Inventory: Entity ...
stevenmahony's user avatar
1 vote
0 answers
705 views

I am using Entity Framework Core 6.0 and SQL Server. I am trying to update a relational database to reflect this diagram: ER Diagram where a single red line over a relationship represents ON DELETE ...
Gravy's user avatar
  • 11
1 vote
1 answer
1k views

I have two entities, Movie and UserRating. I want to be able to specify table names and column names myself. UserRating shall have a foreign key to Movie in the database, but I'd like both entities in ...
dropbear's user avatar
  • 1,767
1 vote
1 answer
190 views

I would like to create internal mapping of navigation property to specific table using EF's fluent API. Meaning - Same type is mapped to different tables according to parent type (see code below) ...
Roi Shabtai's user avatar
  • 3,091
2 votes
2 answers
3k views

Problem - I need to create some type of mapping between 2 entities with property "SourceTransactionId", where either entity can be added to the db first, before the other, but still be able ...
chuckd's user avatar
  • 14.8k
0 votes
1 answer
81 views

I had mistake, but does not understand where. When I`m add to my database object they saved correct, unfortunately not equals my image, maybe it`s my mistake. I need hint to where look. For the sake ...
tender's user avatar
  • 69
2 votes
0 answers
58 views

I have two entities from separate aggregate groups that have a many-to-many relationship: public class ClientNotificationMethod { public int ID { get; private set; } private ...
jmagen's user avatar
  • 21
1 vote
1 answer
269 views

There are two ORM in my .NET Core 6.0 project, Entity Framework and Dapper. I would like to share the Fluent API with Dapper. Is there any way to do this? The main goal is to centralize the mapping of ...
Mesquita Engineer's user avatar
1 vote
1 answer
529 views

If I put [Required] attribue over a property in a model then the <input> helper tag will throw out a validation error if no value is provided, but also it will be affecting database structure. ...
Yoda's user avatar
  • 18.2k
1 vote
1 answer
2k views

I have recently been using PostgreSQL rather than SQL, so finding a lot of little nuances between the two. I want to be able to make a string value unique in a table, so using the EF code first fluent ...
Tim B James's user avatar
  • 20.4k
0 votes
1 answer
559 views

I've seen this question posted previously but I've implemented all the accepted answers in my code and I'm still getting the error. I have a number of classes (Client, Supplier etc) that each have a ...
mdicoope's user avatar
1 vote
1 answer
100 views

I have specified: public class Cart { public int Id { get; set; } public virtual ApplicationUser ApplicationUser { get; set; } } public class ApplicationUser : IdentityUser { public ...
Yoda's user avatar
  • 18.2k
1 vote
0 answers
269 views

I have an exiting database and I wanted to perform crud operations on it. I am using asp.net core 3.1 web api. All my database tables are defined in snake case naming convention e.g my_table_name ...
Sohaib Sarwar's user avatar
0 votes
0 answers
203 views

I have a base class with some properties and 10 derived types, 2 of them have a navigation property to another table, both of them are configured the same way, one is working and the other is not. ...
Mainumbi's user avatar
2 votes
1 answer
445 views

I know how to add and edit custom columns to AspNetUsers. I am asking how to change the default ones. I tried using the Fluent API in the DbContext file, but nothing changes. My Visual Studio is - ...
FadoBagi's user avatar
  • 191
0 votes
3 answers
761 views

I created my first initial migration with some tables and columns, but I saw a thing, all my fields are not null and to every field which I want nullable (almost all) I need to specify the IsRequired(...
Alex's user avatar
  • 1,170
1 vote
0 answers
40 views

we have a SQL database setup like this Table 1 Tasks ------------- TenantId int TaskId int TypeId int Table2 TaskTypes ---------------- TenantId int TypeId int Name varchar(100) Language varchar(2) ...
Ben Croughs's user avatar
  • 2,673
2 votes
0 answers
71 views

I am developping a .net core app with 4 projects core (where models are defined) infrastructure (contains migrations and fluent api for core entities) app (business logic) web (razor pages and ...
JMC's user avatar
  • 21
0 votes
1 answer
181 views

There are a lot of examples how to use Fluent API in the internet, but mostly shows how configure one relationship between two models. In my case I need 3 relationships between 2 models. How to ...
Lexs's user avatar
  • 25
-1 votes
1 answer
365 views

I am using EF Core Code-First Approach to configure/map an entity class named Student to SQL Server table named Student. The Student entity model class has a string column named Name that will be ...
Thomas.Benz's user avatar
  • 8,619
1 vote
1 answer
358 views

I have a string property it is configured as IsRequired() using FluentAPI. How do I check if this property is required? I'm iterating through all properties of my object using reflection.
User123's user avatar
  • 619
0 votes
1 answer
195 views

I am using .NET 6 to develop EF Core MVC program, The concept is single User can have multiple roles, and the role data is create by a User from another system. I have a base class EntityBase.cs : ...
Howard Hee's user avatar

1
2 3 4 5
17