EntityFramework ORA-00955 名称已由现有对象使用

Oracle implementation of Entity framework provider is very poor but there are some ways how to make this working.

  1. 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.

  1. 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 from ALL_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.
posted @ 2017-12-29 14:40  Farmer.D  阅读(651)  评论(0编辑  收藏  举报