EF Code First - The Type clob is not qualified with a namesp

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
DavidC
Posts: 2
Joined: Thu 14 Jul 2011 10:01
Location: UK

EF Code First - The Type clob is not qualified with a namesp

Post by DavidC » Thu 14 Jul 2011 10:17

Using Entity Framework Code First to connect to Legacy Oracle Database with devart dotconnect.

I keep getting this error:
The Type clob is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.

I have been trying out to use EF 4.1 (code first) with MVC 3, against a legacy Oracle 10g database, using devart dotconnect. The legacy database **cannot** be changed. I'm trying to read the data in it out to a webpage.

(Devart.Data.Oracle Version: 5.70.140.0)

I've had a few errors to overcome along the way, but came to this one.

This is my code:

Web.config connection info:

Code: Select all

   

Code: Select all

    namespace AllInOne
    {
    	public class OdeToTrainingCoursesDB : DbContext
    	{
    		public DbSet VENUES { get; set; }
    	}
    }

Code: Select all

    using System.ComponentModel.DataAnnotations;
    
    namespace AllInOne.Models
    {
    	public class VENUES
    	{
    		[Key]
    		public int VENUE_ID { get; set; }
    	}
    }
This is the first table (of many) that I'm trying to read from.

Code: Select all

    CREATE TABLE VENUES
    (
      VENUE_ID    NUMBER(10)                        NOT NULL,
      VENUE_TYP   VARCHAR2(1 BYTE),
      BASE_ORG    NUMBER(10)                        NOT NULL,
      COUNTY      VARCHAR2(35 BYTE)
    )

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 14 Jul 2011 12:59

This particular problem can be solved by removing ColumnTypeCasingConvention:

Code: Select all

modelBuilder.Conventions.Remove();
However, I recommend you to refer to our Code First article, it contains a number of useful recommendations.
Here is the code I used to get the values from your table:

Code: Select all

  class Program {
    static void Main(string[] args) {

      OracleEntityProviderConfig config = OracleEntityProviderConfig.Instance;
      config.Workarounds.IgnoreSchemaName = true;
      using(var context = new OdeToTrainingCoursesDB()){
        var q = context.VENUES.ToList();
      }
    }
  }

  public class OdeToTrainingCoursesDB : DbContext { 
    public DbSet VENUES { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder) {

      modelBuilder.Conventions.Remove();
      base.OnModelCreating(modelBuilder);
    }
  }

  public class VENUES {
    [Key]
    public int VENUE_ID { get; set; }
    public string VENUE_TYP { get; set; }
    public int BASE_ORG { get; set; }
    public string COUNTY { get; set; }
  }
You can try to use the DbContext template, it is designed for generating the Code First-like code for the legacy databases.
However, the current version contains an error. I have sent a working template to the e-mail address provided in your forum profile.

DavidC
Posts: 2
Joined: Thu 14 Jul 2011 10:01
Location: UK

Post by DavidC » Thu 14 Jul 2011 13:22

Worked a treat, thanks for the fast and comprehensive response. :D

Post Reply