EnLabSoftware / HRManagement

109 stars 61 forks source link

Why Context does not have DbSet<>? #1

Open Ar33ss opened 2 years ago

Ar33ss commented 2 years ago

I am trying to learn the architecture but cannot understand why Context does not have DbSet<> tables. For example:

public DbSet <Department> Departments {get;set;}
public DbSet <User> Users {get;set;}

When running migrations, tables are not creating in the database.

Even adding them to DbContext this error shows up:

The entity type 'BaseDomainEvent' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943.

Even ignoring DbSet<> running the API project when hitting Users shows this error:

System.InvalidOperationException: Cannot create a DbSet for 'User' because this type is not included in the model for the context.

I did a migration in VSCode.

dotnet ef migrations add initialcreation1 -s ../API/API.csproj dotnet ef database update -s ../API/API.csproj

blackcrow-it commented 10 months ago

Have you fixed this error yet?