0

I have the following class from which I have marked all non-primitives with the [NotMapped] attribute. Yet it continues to give me the following error:

I am using:

  • VS 2010 SP1
  • .Net 4.0 (C#) - WinForms
  • Entity Framework 5.0 Code First
  • SQL Compact (CE) 3.5

The type 'MySolution.Core.Blob' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject.

[System.ComponentModel.DataAnnotations.Schema.Table("Blob")]
public partial class Blob
{
    [System.ComponentModel.DataAnnotations.Schema.NotMapped]
    private AForge.Imaging.Blob BlobInternal { get; set; }

    public Blob ()
    {
        this.BlobInternal = new AForge.Imaging.Blob(0, new System.Drawing.Rectangle());
    }

    public Blob (int id, System.Drawing.Rectangle rect)
    {
        this.BlobInternal = new AForge.Imaging.Blob(id, rect);
    }

    public Blob (AForge.Imaging.Blob source)
    {
        this.BlobInternal = new AForge.Imaging.Blob(source);
    }

    [System.ComponentModel.DataAnnotations.Schema.Column("OriginalSize")]
    public bool OriginalSize { get { return (this.BlobInternal.OriginalSize); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("Id")]
    public int Id { get { return (this.BlobInternal.ID); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("Area")]
    public int Area { get { return (this.BlobInternal.Area); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("Fullness")]
    public double Fullness { get { return (this.BlobInternal.Fullness); } }

    [System.ComponentModel.DataAnnotations.Schema.NotMapped]
    public AForge.Point CenterOfGravity { get { return (this.BlobInternal.CenterOfGravity); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("CenterOfGravityX")]
    public float CenterOfGravityX { get { return (this.BlobInternal.CenterOfGravity.X); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("CenterOfGravityY")]
    public float CenterOfGravityY { get { return (this.BlobInternal.CenterOfGravity.Y); } }

    [System.ComponentModel.DataAnnotations.Schema.NotMapped]
    public System.Drawing.Rectangle Rectangle { get { return (this.BlobInternal.Rectangle); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("RectangleX")]
    public int RectangleX { get { return (this.BlobInternal.Rectangle.X); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("RectangleY")]
    public int RectangleY { get { return (this.BlobInternal.Rectangle.Y); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("RectangleW")]
    public int RectangleW { get { return (this.BlobInternal.Rectangle.Width); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("RectangleH")]
    public int RectangleH { get { return (this.BlobInternal.Rectangle.Height); } }

    [System.ComponentModel.DataAnnotations.Schema.NotMapped]
    public System.Drawing.Color ColorMean { get { return (this.BlobInternal.ColorMean); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorMeanA")]
    public byte ColorMeanA { get { return (this.BlobInternal.ColorMean.A); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorMeanR")]
    public byte ColorMeanR { get { return (this.BlobInternal.ColorMean.R); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorMeanG")]
    public byte ColorMeanG { get { return (this.BlobInternal.ColorMean.G); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorMeanB")]
    public byte ColorMeanB { get { return (this.BlobInternal.ColorMean.B); } }

    [System.ComponentModel.DataAnnotations.Schema.NotMapped]
    public System.Drawing.Color ColorStdDev { get { return (this.BlobInternal.ColorStdDev); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorStdDevA")]
    public byte ColorStdDevA { get { return (this.BlobInternal.ColorStdDev.A); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorStdDevR")]
    public byte ColorStdDevR { get { return (this.BlobInternal.ColorStdDev.R); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorStdDevG")]
    public byte ColorStdDevG { get { return (this.BlobInternal.ColorStdDev.G); } }

    [System.ComponentModel.DataAnnotations.Schema.Column("ColorStdDevB")]
    public byte ColorStdDevB { get { return (this.BlobInternal.ColorStdDev.B); } }

    [System.ComponentModel.DataAnnotations.Schema.NotMapped]
    public AForge.Imaging.UnmanagedImage Image { get { return (this.BlobInternal.Image); } }
}
4
  • Blob is a partial class, do you have any other part of the Blob class inheriting from EntityObject? Commented Jan 31, 2013 at 23:46
  • No. It is only partial so I can generate standard code using T4. It implements multiple interfaces but nothing to do with EntityObject. Commented Jan 31, 2013 at 23:47
  • Could you comment out the last two constructors and try it out please ? Commented Feb 1, 2013 at 0:31
  • Found the problem. It had to do another class that was referencing Blob and had some non-primitives. Commented Feb 2, 2013 at 11:25

1 Answer 1

1

If you want to use the EF Code Fisrt with SQL CE you need to configure the ConectionFactory for it.

You can to see that the only line for the EF run with the SQL CE is this:

Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.3.5");

A exemple that you can to download in the MSDN Gallery

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.