Support for storing keys using Entity Framework Core. This package was built from the source code at https://github.com/dotnet/dotnet/tree/87bc0b04e21d786669142109a5128c95618b75ed
$ dotnet add package Microsoft.AspNetCore.DataProtection.EntityFrameworkCoreMicrosoft.AspNetCore.DataProtection.EntityFrameworkCore provides a mechanism for storing data protection keys to a database using Entity Framework Core.
To use Microsoft.AspNetCore.DataProtection.EntityFrameworkCore, follow these steps:
dotnet add package Microsoft.AspNetCore.DataProtection.EntityFrameworkCore
To store keys in a database, use the PersistKeysToDbContext extension method. For example:
builder.Services.AddDataProtection()
.PersistKeysToDbContext<MyDbContext>();
Ensure that your DB context (MyDbContext in the above example) implements IDataProtectionKeyContext. For example:
class MyDbContext : DbContext, IDataProtectionKeyContext
{
public MyKeysContext(DbContextOptions<MyKeysContext> options)
: base(options)
{
}
// This maps to the table that stores keys
public DbSet<DataProtectionKey> DataProtectionKeys { get; set; }
}
For additional documentation and examples, refer to the official documentation on the Entity Framework Core key storage provider.
Microsoft.AspNetCore.DataProtection.EntityFrameworkCore is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.