Oracle implementation of Entity framework provider is very poor but there are some ways how to make this working.
-
Simple but annoying - using NULL or own database initializer implementation:
Database.SetInitializer<DatabaseContext>(null);
or
class DatabaseInitializer : IDatabaseInitializer<DatabaseContext>
{
public void InitializeDatabase(DatabaseContext context)
{
// your implementation
}
}
Database.SetInitializer(new DatabaseInitializer());
Set the initialized before first access to your database.
- If you want to use migrations create your views and then add migration with ignoring changes, for instance using package console
add-migration initial -ignorechanges
. This will make EF ignoring the inconsistencies between the DB schema and model (because it checks only tables fromALL_TABLES
, not views) so it will not try to create table. There is a bug in Oracle EF implementation that if the initial migration is empty it drops and recreates the__MigrationHistory
table so either your initial migration must containt at least one table before you add the view migration or you need to add a table afterwards.