Home > Enterprise >  EF Core DataSets on DbContext are all null despite data being in the database
EF Core DataSets on DbContext are all null despite data being in the database

Time:11-07

I have a project (this is a play project so don't freak out about security here), enter image description here I am using SQL Server although I tried with postgresql as well. This is on my local machine for right now.

I have successfully added the migrations, updated the database and verified that the data was added.

enter image description here

I have tried switching database and providers (postgresql to sql server). I have even tried to start a new context, but no dice. The only thing I haven't tried is sacrificing a lamb to the coding gods.

Any advice is much appreciated. Thanks!

CodePudding user response:

You need a public setter for DbSet in EF.

In your AuthHubContext.cs, change

public DbSet<User> Users;

to

public DbSet<User> Users {get; set;}
  • Related