oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
413 stars 191 forks source link

Oracle.EntityFrameworkCore 6.21.61 -> EnsureDeletedAsync no deletes database but returns true #252

Closed meriturva closed 2 years ago

meriturva commented 2 years ago

is it EnsureDeletedAsync method supported by Oracle Data Provider for .NET (ODP.NET) Entity Framework Core 6.21.61?

On my tests method returns true (true if the database is deleted, false if it did not exist) but no effect on db.

Thanks.

alexkeh commented 2 years ago

EnsureDeleted is supported. You can try that. Here's the ODP.NET EnsureDeleted doc link.

One thing to note is that "The return value is true if an attempt is made to drop all user created objects related to the schema in the current context."

Was there a command to drop the objects, but was blocked from executing successfully for some reason, such as a permission issue? If not, what version DB are you using and can you publish any trace/logs about what EnsureDeleted* did during execution?

meriturva commented 2 years ago

I found where is issue. Actually, I use docker image wnameless/oracle-xe-11g-r2 that uses system user as default. So I presume all user-created objects could not be deleted where user is system,. What I think is incorrect is the return value of oracle implementation of method EnsureDeletedAsync.

I mean, on ef core doc we have result described as The task result contains true if the database is deleted, false if it did not exist see: https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.infrastructure.databasefacade.ensuredeletedasync?view=efcore-6.0#returns

but on oracle side we have attempt.

Any way to improve it?

Thanks.

alexkeh commented 2 years ago

What should the EnsureDeletedAsync return value be if the delete was only partially complete or not done and the schema does exist? That scenario is possible because most DBs will limit the sysadmin from deleting all their objects. Or if a normal user's delete privileges have been revoked for some or all its objects.

The DB doesn't have to be Oracle. It can be SQL Server. Whether the result is true or false, the result of an incomplete DELETE would be inaccurate from EnsureDeletedAsync.

meriturva commented 2 years ago

When system user is used EnsureDeletedAsync doesn't delete anything and returns true. Anyway, I close the issue, usually system is not the correct user to use, even during integration tests.