dotnetcore / EntityFrameworkCore.KingbaseES

Entity Framework Core provider for KingbaseES Database
PostgreSQL License
43 stars 6 forks source link

EfCore执行 add-migration ,update-database时出现以下错误,postgres是在哪儿设置的? #10

Open YoChen opened 2 months ago

YoChen commented 2 months ago

Kdbndp.KingbaseException (0x80004005): 3D000: database "postgres" does not exist at Kdbndp.KdbndpConnector.<>c__DisplayClass166_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext() --- End of stack trace from previous location --- at Kdbndp.KdbndpConnector.<>c__DisplayClass166_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext() --- End of stack trace from previous location --- at Kdbndp.KdbndpConnector.Open(KdbndpTimeout timeout, Boolean async, CancellationToken cancellationToken) at Kdbndp.KdbndpConnection.<>c__DisplayClass34_0.<<Open>g__OpenLong|0>d.MoveNext() --- End of stack trace from previous location --- at Kdbndp.KdbndpConnection.Open() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable1 migrationCommands, IRelationalConnection connection) at Kdbndp.EntityFrameworkCore.KingbaseES.Storage.Internal.KdbndpDatabaseCreator.Create() at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) 3D000: database "postgres" does not exist`

YoChen commented 2 months ago

临时解决办法:

新建一个postgres空数据库,然后再执行迁移就可以了。

YoChen commented 2 months ago

`Configure(options => { /* The main point to change your DBMS.

b.UseAdminDatabase("kingbase"); 或是在配置数据库上下文时增加这句?

wangpengxpy commented 2 months ago

没明白你的问题,看异常信息是连接的数据库postgres不存在

hatzhang commented 3 weeks ago

根据我使用的经验,这个错会在连接一个不存在的库时出现。如以下连接串

host=localhost;port=4321;database=TestAAA;user id=system;password=123456;

如果TestAAA不存在,就会报这个错。倒不是说postgres这个库不存在。 在使用SqlServer的EFCore时,库不存在会主动创建。不知道Kingbase这个能不能也这样?