Re: [EF.Core] How to create DbContext for existing DbConnection?
Posted: Thu 02 Nov 2017 15:18
You have encountered the exception with the following test, haven't you?
We cannot reproduce the problem in our environment at the moment. Please run your code in the debug mode and make sure that the only Devart.Data.Oracle.Entity.EFCore.dll loaded in the process of your application is C:\Program Files (x86)\Devart\dotConnect\Oracle\Entity\EFCore2\Devart.Data.Oracle.Entity.EFCore.dll.
If this doesn't help, please upload a simple test project to some file exchange server.
Code: Select all
[TestMethod]
public void DbContext_With_DbConnection_EnsureDeleted()
{
// Works fine with .UseOracle(ConnectionString)
using (var dbContext = new TestDbContext(ConnectionString))
{
dbContext.Database.EnsureDeleted();
}
// Fails with .UseOracle(DbConnection)
using (var dbConnection = new OracleConnection { ConnectionString = ConnectionString })
{
using (var dbContext = new TestDbContext(dbConnection))
{
dbContext.Database.EnsureDeleted();
}
}
}
If this doesn't help, please upload a simple test project to some file exchange server.