none
Code First Model generates extra columns on other PC but not my Dev PC RRS feed

  • Question

  • I have a code first model and working with EF 4.1

    Everything is working fine on my Dev PC.  We have a Ria Services Silverlight app and that is deployed/hosted by a Win 2008 server which is working fine as well.

    I tried to deploy another app that uses this model and it is failing with SQL statement that includes some bogus column names.  I can't figure out why it would have a different 'schema' than my Dev PC.

    Perhaps there is something wrong with how I am using the model attributes?

    On the server, the sql has two extra columns: "Collector_UserId" and "Receiver_UserId"

    Here is the entity that is failing:

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Reflection;
    using System.ServiceModel.DomainServices.Server;
    using log4net;
    
    namespace Cul2.Model
    {
        [Table("LAB_REQUISITION")]
        public class LabRequisition : EntityBase
        {
            public LabRequisition()
            {
                Attributes = new Collection<LabRequisitionAttribute>();
                Samples = new Collection<LabSample>();
            }
    
            [Key]
            [Column("REQUISITION_ID")]
            public long? RequisitionId { get; set; }
    
            [Column("MATERIAL_ID")]
            public long? MaterialId { get; set; }
    
            [Include]
            [Association("Material", "MaterialId", "MaterialId", IsForeignKey = true)]
            public virtual LabMaterial Material { get; set; }
    
            [Column("LAB_NUMBER")]
            public int? LabNumber { get; set; }
    
            [Column("COLLECTOR_ID")]
            public long? CollectorId { get; set; }
    
            [Include]
            [Association("Collector", "CollectorId", "UserId")]
            [ForeignKey("CollectorId")]
            public virtual ComUser Collector { get; set; }
    
            [Column("RECEIVER_ID")]
            public long? ReceiverId { get; set; }
    
            [Include]
            [Association("Receiver", "ReceiverId", "UserId")]
            [ForeignKey("ReceiverId")]
            public virtual ComUser Receiver { get; set; }
    
            [Column("COLLECTION_DATE")]
            public DateTime? CollectionDate { get; set; }
    
            [Column("STATUS_ID")]
            public long? StatusId { get; set; }
    
            [Include]
            [Association("Status", "StatusId", "StatusId", IsForeignKey = true)]
            public virtual LabStatus Status { get; set; }
    
            [Column("IS_ACTIVE")]
            public bool IsActive { get; set; }
    
            [Column("TEMPLATE_ID")]
            public long? TemplateId { get; set; }
    
            [Include]
            [Association("Template", "TemplateId", "TemplateId", IsForeignKey = true)]
            public virtual LabTemplate Template { get; set; }
    
            [Column("REASON_ID")]
            public long? ReasonId { get; set; }
    
            [Include]
            [Association("Reason", "ReasonId", "ReasonId", IsForeignKey = true)]
            public virtual LabReason Reason { get; set; }
    
            [Column("RECEIVED_DATE")]
            public DateTime? ReceivedDate { get; set; }
    
            [Include]
            [Association("Samples", "RequisitionId", "RequisitionId")]
            [ForeignKey("RequisitionId")]
            public ICollection<LabSample> Samples { get; set; }
    
            [Include]
            [Association("Attributes", "RequisitionId", "RequisitionId")]
            public ICollection<LabRequisitionAttribute> Attributes { get; set; }
    
            public override string ToString()
            {
                return LabNumber == null ? "New" : LabNumber.ToString();
            }
        }
    }

    On my Dev PC, if I dump the create sql for the schema, the table looks like this:

    -- Table LAB_REQUISITION
    CREATE TABLE LAB_REQUISITION ( 
      REQUISITION_ID NUMBER(18) NOT NULL,
      MATERIAL_ID NUMBER(18) NULL,
      LAB_NUMBER NUMBER(10) NULL,
      COLLECTOR_ID NUMBER(18) NULL,
      RECEIVER_ID NUMBER(18) NULL,
      COLLECTION_DATE TIMESTAMP(7) NULL,
      STATUS_ID NUMBER(18) NULL,
      IS_ACTIVE NUMBER(1) NOT NULL,
      TEMPLATE_ID NUMBER(18) NULL,
      REASON_ID NUMBER(18) NULL,
      RECEIVED_DATE TIMESTAMP(7) NULL,
      ROW_VERSION NUMBER(18,2) NULL,
      CREATED TIMESTAMP(7) NULL,
      CREATED_BY_ID NUMBER(18) NULL,
      LAST_UPDATED TIMESTAMP(7) NULL,
      LAST_UPDATED_BY_ID NUMBER(18) NULL,
      PRIMARY KEY (REQUISITION_ID)
    )
    /

    On the server, the schema sql looks like this:

    -- Table LAB_REQUISITION
    CREATE TABLE LAB_REQUISITION ( 
      REQUISITION_ID NUMBER(18) NOT NULL,
      MATERIAL_ID NUMBER(18) NULL,
      LAB_NUMBER NUMBER(10) NULL,
      COLLECTOR_ID NUMBER(18) NULL,
      RECEIVER_ID NUMBER(18) NULL,
      COLLECTION_DATE TIMESTAMP(7) NULL,
      STATUS_ID NUMBER(18) NULL,
      IS_ACTIVE NUMBER(1) NOT NULL,
      TEMPLATE_ID NUMBER(18) NULL,
      REASON_ID NUMBER(18) NULL,
      RECEIVED_DATE TIMESTAMP(7) NULL,
      ROW_VERSION NUMBER(18,2) NULL,
      CREATED TIMESTAMP(7) NULL,
      CREATED_BY_ID NUMBER(18) NULL,
      LAST_UPDATED TIMESTAMP(7) NULL,
      LAST_UPDATED_BY_ID NUMBER(18) NULL,
      "Collector_UserId" NUMBER(18) NULL,
      "Receiver_UserId" NUMBER(18) NULL,
      PRIMARY KEY (REQUISITION_ID)
    )
    /

    We are using oracle databases, so we are using Devart dotConnect for our data provider.

    For fun I tried updating EF to EF5 but that didn't change anything, the server sql still had the two extra columns and the dev pc was correct.

    Tuesday, October 30, 2012 3:28 PM

Answers