EF6 Beta 1 Support - Oracle

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
John Liu
Posts: 61
Joined: Wed 14 Nov 2012 20:58

EF6 Beta 1 Support - Oracle

Post by John Liu » Mon 10 Jun 2013 23:43

Hi,
My code worked fine with EF6 Alpha 3 for both Sql Server and Oracle. I just upgraded to EF 6 Beta 1 and made the code to work with Sql server OK. I'm having issues to make it work with an Oracle database. I just installed your latest dotConnect for Oracle (7.7.257.6). I'm having issues on the config file. I've included my app.config and the error messages
thanks
JL


<?xml version="1.0"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwGeneralComment/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<connectionStrings>
<!--<add name="CwDbContext" connectionString="Server=.\SQLEXPRESS;Database=CWDBNEW;User ID=az;Password=sys" providerName="System.Data.SqlClient"/>-->
<add name="CwDbContext" connectionString="server=192.168.20.86;direct=True;sid=CWDB;user id=az;Password=sys;" providerName="Devart.Data.Oracle" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
<provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=7.7.257.6, Culture=neutral, PublicKeyToken=09af7300eec23701">
<migrationSqlGenerator type="Devart.Data.Oracle.Entity.Migrations.OracleEntityMigrationSqlGenerator, Devart.Data.Oracle.Entity, Version=7.7.257.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</provider>
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Devart.Data.Oracle"/>
<add name="dotConnect for Oracle" invariant="Devart.Data.Oracle" description="Devart dotConnect for Oracle" type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=7.7.257.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
</DbProviderFactories>
</system.data>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>


PM> get-migrations
Retrieving migrations that have been applied to the target database.
System.TypeInitializationException: The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Unrecognized element 'migrationSqlGenerator'. (C:\CWSource\Cityworks Server\Cityworks.DataAccess\tmpB409.tmp line 16)
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Data.Entity.Internal.AppConfig..ctor()
at System.Data.Entity.Internal.AppConfig..cctor()
--- End of inner exception stack trace ---
at System.Data.Entity.Config.DbConfigurationManager.EnsureLoadedForContext(Type contextType)
at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..cctor()
--- End of inner exception stack trace ---
at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..ctor()
at Cityworks.DataAccess.Configuration..ctor() in c:\CWSource\Cityworks Server\Cityworks.DataAccess\Migrations\Configuration.cs:line 19
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
at System.Data.Entity.Migrations.Design.ToolingFacade.GetDatabaseMigrationsRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.GetDatabaseMigrations()
at System.Data.Entity.Migrations.GetMigrationsCommand.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: EF6 Beta 1 Support - Oracle

Post by Shalex » Tue 11 Jun 2013 14:47

According to the exception and stack trace, this is a Microsoft's bug with setting migrationSqlGenerator via *.config in Entity Framework 6. Please set it in the code: http://blogs.devart.com/dotconnect/enti ... Migrations.

John Liu
Posts: 61
Joined: Wed 14 Nov 2012 20:58

Re: EF6 Beta 1 Support - Oracle

Post by John Liu » Tue 11 Jun 2013 17:21

Yes. That fixed the problem.
Thank you very much! but I've another issue.
A lot of index and constraint names are more than 30 characters. You provides a way to rename them using unique integers. However, the generation those integers seems depend on which approach used to upgrade the database. I've three ways to upgrade the database.
1. Package Manager Console, 2. Command line - Migrate.exe, 3. Unit test code. Running up and down migration using only one of the three approaches work correctly. If running up migration using one of three approaches, and running down migration using a different approach will get a error.
thanks
JL

PM> update-database -targetmigration 0 -verbose
Using StartUp project 'Cityworks.DataAccess'.
Using NuGet project 'Cityworks.DataAccess'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: '' (DataSource: 192.168.20.86, Provider: Devart.Data.Oracle, Origin: Configuration).
Reverting migrations: [201306071751211_V20120100].
Reverting explicit migration: 201306071751211_V20120100.
ALTER TABLE AZTECA.CA_REL_DOCS DROP CONSTRAINT CW_CONSTRAINT_1
Devart.Data.Oracle.OracleException (0x80004005): ORA-02443: Cannot drop constraint - nonexistent constraint
at Devart.Data.Oracle.b2.d()
at Devart.Data.Oracle.cd.f()
at Devart.Data.Oracle.cd.c()
at Devart.Data.Oracle.i.a(Int32 A_0, ca A_1)
at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Data.Oracle.OracleCommand.ExecuteNonQuery()
at System.Data.Entity.Infrastructure.InternalDispatcher`1.Dispatch[TResult](Func`1 operation, Action`1 executing, Func`3 executed)
at System.Data.Entity.Infrastructure.DbCommandDispatcher.NonQuery(DbCommand command, DbInterceptionContext interceptionContext)
at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass2f.<ExecuteStatements>b__2b()
at System.Data.Entity.Infrastructure.NonRetryingExecutionStrategy.Execute(Action action)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.RevertMigration(String migrationId, DbMigration migration, XDocument targetModel)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.RevertMigration(String migrationId, DbMigration migration, XDocument targetModel)
at System.Data.Entity.Migrations.DbMigrator.Downgrade(IEnumerable`1 pendingMigrations)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Downgrade(IEnumerable`1 pendingMigrations)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass9.<Update>b__8()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
ORA-02443: Cannot drop constraint - nonexistent constraint

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: EF6 Beta 1 Support - Oracle

Post by Shalex » Tue 18 Jun 2013 07:39

We cannot reproduce the problem in our environment. Please send us a small test project and specify the exact steps we should follow to reproduce the issue in our environment.

Post Reply