Error Running Code First Migrations

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
ndroe
Posts: 18
Joined: Fri 03 Feb 2012 16:08

Error Running Code First Migrations

Post by ndroe » Fri 03 Feb 2012 16:15

I'm getting the following errors when I attempt to execute "Update-Database" from the package manager console:
Schema specified is not valid. Errors:
(7,6) : error 0040: The Type nvarchar2 is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.
(8,6) : error 0040: The Type timestamp is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.
(9,6) : error 0040: The Type blob is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.
(10,6) : error 0040: The Type nvarchar2 is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.
My migration configuration looks like this:

Code: Select all

internal sealed class Configuration : DbMigrationsConfiguration
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
            SetSqlGenerator("Devart.Data.Oracle", new OracleEntityMigrationSqlGenerator());
        }
}
and my data context looks like this:

Code: Select all

public class MyDbContet : DbContext
{
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<ColumnTypeCasingConvention>();
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
 
            // My code first entity configurations are loaded here    
        } 
}
What am I doing wrong?

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

Post by Shalex » Tue 07 Feb 2012 15:28

You should make the following settings for using EF Code-First Migrations with dotConnect for Oracle:

Code: Select all

  var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;  
  config.Workarounds.IgnoreSchemaName = true;
  config.Workarounds.ColumnTypeCasingConventionCompatibility = true;
After this, there is no need to turn off these conventions:

Code: Select all

  modelBuilder.Conventions.Remove<ColumnTypeCasingConvention>();
  modelBuilder.Conventions.Remove<IncludeMetadataConvention>();

HelluvaEngineer
Posts: 4
Joined: Tue 15 May 2012 18:45

Re: Error Running Code First Migrations

Post by HelluvaEngineer » Tue 15 May 2012 18:52

I am encountering this same exact problem, but at run-time. I used Entity Developer to generate my code. After applying the fix you mentioned, I now have a ton of errors that look like this:

Code: Select all

(19,6) : error 0040: The Type VARCHAR2 is not qualified with a namespace or alia
s. Only PrimitiveTypes can be used without qualification.
(20,6) : error 0040: The Type DATE is not qualified with a namespace or alias. O
nly PrimitiveTypes can be used without qualification.
(21,6) : error 0040: The Type VARCHAR2 is not qualified with a namespace or alia
s. Only PrimitiveTypes can be used without qualification.
(22,6) : error 0040: The Type VARCHAR2 is not qualified with a namespace or alia
s. Only PrimitiveTypes can be used without qualification.
(23,6) : error 0040: The Type DATE is not qualified with a namespace or alias. O
nly PrimitiveTypes can be used without qualification.
Any ideas? Thanks.

HelluvaEngineer
Posts: 4
Joined: Tue 15 May 2012 18:45

Re: Error Running Code First Migrations

Post by HelluvaEngineer » Tue 15 May 2012 18:53

This is using the Fluent Mapping.

Also, your contact us page appears to be borked.

Code: Select all

[NullReferenceException: Object reference not set to an instance of an object.]
   ContactPage.SendMessage() +457
   ContactPage.btnSend_Click(Object sender, EventArgs e) +33
   CustomButton.OnClick() +79
   CustomButton.button_Click(Object sender, EventArgs e) +5
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

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

Re: Error Running Code First Migrations

Post by Shalex » Mon 21 May 2012 08:13

The behaviour will be changed starting from the next build of dotConnect for Oracle: when FluentMapping=true and DatabaseIndependent=false, the DbContext template will generate the server types names which are compatible with the ColumnTypeCasingConventionCompatibility mode. We will post here when the corresponding build of dotConnect for Oracle is available for download.

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

Re: Error Running Code First Migrations

Post by Shalex » Wed 23 May 2012 15:52

New version of dotConnect for Oracle 7.0 is released!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=24180 .

cbruen1
Posts: 9
Joined: Wed 23 Nov 2011 20:18

Re: Error Running Code First Migrations

Post by cbruen1 » Mon 04 Mar 2013 16:34

Hi, I'm also getting similar errors to the OP. I haven't enabled and of the migrations functionality yet, just upgraded EF and dotConnect. I was using EF 4.2 Code First and dotConnect 6.8. I upgraded EF to version 4.3.1 and dotConenct to version 7, and am seeing these errors at run time on the first access of the database:

(7,6) : error 0040: The Type nvarchar2 is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(8,6) : error 0040: The Type timestamp is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(9,6) : error 0040: The Type blob is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(10,6) : error 0040: The Type nvarchar2 is not qualified with a namespace or alias. Only primitive types can be used without qualification.

Any ideas??

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

Re: Error Running Code First Migrations

Post by Shalex » Tue 05 Mar 2013 13:51

Could you please try setting "ColumnTypeCasingConventionCompatibility = true" explicitly in *.config or before the first usage of the context?

cbruen1
Posts: 9
Joined: Wed 23 Nov 2011 20:18

Re: Error Running Code First Migrations

Post by cbruen1 » Tue 05 Mar 2013 16:45

Hi, thanks I eventually found out that's what was needed so I added this to OnModelCreating:

Code: Select all

var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
            config.Workarounds.IgnoreSchemaName = true;
            config.Workarounds.ColumnTypeCasingConventionCompatibility = true;
I also upgraded to version 7.6 of dotConnect.

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

Re: Error Running Code First Migrations

Post by Shalex » Wed 06 Mar 2013 07:03

If you use Code-First Migrations, the code from OnModelCreating will not be executed. In this case the settings should be made in static constructor (implement it manually in a partial class) or in *.config:

Code: Select all

<configuration>
  <configSections>
    <section name="Devart.Data.Oracle.Entity" type="Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfigurationSection,
      Devart.Data.Oracle.Entity, Version=7.6.192.0, Culture=neutral,
      PublicKeyToken=09af7300eec23701" />
  </configSections>
  <Devart.Data.Oracle.Entity xmlns="http://devart.com/schemas/Devart.Data.Oracle.Entity/1.0">
    <CodeFirstOptions ColumnTypeCasingConventionCompatibility="true"/>
  </Devart.Data.Oracle.Entity>
</configuration>

Post Reply