I created a project using the .NET Core react + individual user authentication template.
I am trying to declare other entities inside ApiAuthorizationDbContext<TUser>
class but they somehow don't seem to appear in the database.
public class ApplicationDbContext : ApiAuthorizationDbContext<ApplicationUser>
{
public ApplicationDbContext(
DbContextOptions options,
IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions)
{
}
public Microsoft.EntityFrameworkCore.DbSet<Student> Students { get; set; }
}
I also have to prefixate them like this public Microsoft.EntityFrameworkCore.DbSet<Student> Students { get; set; }
, otherwise I get this error 'DbSet<>' is an ambiguous reference between 'System.Data.Entity.DbSet<TEntity>' and 'Microsoft.EntityFrameworkCore.DbSet<TEntity>'
.
Take a look on this documentation. In short, you should run migrations like this -
install .net cli tools
open cmd and "cd" to your .csproj
create migration -
dotnet ef migrations add InitialCreate
update db with this command -
dotnet ef database update