-
Notifications
You must be signed in to change notification settings - Fork 249
Description
Hi, I have installed the newest Npgsql.EntityFrameworkCore.PostgreSQL package in my project, and I added the 'hstore' extension like this:
modelBuilder.HasPostgresExtension("hstore");
The migration file content generated like this:
migrationBuilder.AlterDatabase().Annotation("Npgsql:PostgresExtension:hstore", "'hstore', '', ''");
After this, I have my own database initialize process in main function:
var host = BuildWebHost(args);
var serviceProvider = host.Services;
// initialize database
using (var scope = serviceProvider.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<ISDbContext>();
if (dbContext.Database.GetPendingMigrations().Any())
{
dbContext.Database.Migrate();
}
StorageInitializer.Initialize(dbContext, BuilderContext.HostingEnvironment);
}
I invoke the Migrate() function in order to update my database automatically, after this, I checked that the extension 'hstore' already added to my database, but when I insert records to table(which contains a field with data type Dictionary<string, string>) I got this exception: "NpgsqlException: The PostgreSQL type 'hstore', mapped to NpgsqlDbType 'Hstore' isn't present in your database. You may need to install an extension or upgrade to a newer version."
I'm not sure how to resolve this issue, can anybody help me?
Thanks.