Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Context does not have DbSet<>? #1

Open
Ar33ss opened this issue Dec 12, 2021 · 1 comment
Open

Why Context does not have DbSet<>? #1

Ar33ss opened this issue Dec 12, 2021 · 1 comment

Comments

@Ar33ss
Copy link

Ar33ss commented Dec 12, 2021

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

@leungkimming leungkimming mentioned this issue Mar 10, 2022
@blackcrow-it
Copy link

Have you fixed this error yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants