Linq - Class is not an entity?

A

Andy

Hi,

I'm having a problem that occurs during runtime. The error is
System.InvalidOperationException : Invalid association mapping for
member 'MyCompany.Data.Application.Applications.Messages'.
'MyCompany.Data.Application.Applications' is not an entity.

Any ideas? Here's the Applications type:



using System;

using System.Data.Linq;
using MyCompany.Data;
using System.ComponentModel;
using System.Data.Linq.Mapping;

namespace MyCompany.Data.Application {
/// <summary>Represents the <c>Application</c> table.</summary>
[Table( Name = "dbo.vApplication" ), EntityAttributes( EntityName =
"Application" )]
public sealed class Applications :
DataEntity,
INotifyPropertyChanged,
INotifyPropertyChanging
{
#region Columns

private int? applicationId;

/// <summary>Gets or sets the <c>ApplicationGuid</c>.</summary>
[Column( Storage = "applicationId" ), DataField( IsKeyColumn =
true )]
public int? ApplicationId {
get { return applicationId; }
set {
if ( applicationId != value ) {
SendPropertyChanging( "ApplicationId" );
applicationId = value;
SendPropertyChanged( "ApplicationId" );
}
}
}

/// <summary>Gets or sets the <c>ApplicationGuid</c>.</summary>
[Column, DataField]
public Guid? ApplicationGuid { get; set; }

/// <summary>Gets or sets the <c>AppName</c>.</summary>
[Column, DataField]
public String AppName { get; set; }

[Column, DataField]
public String AppInstanceKey { get; set; }

[Column, DataField]
public String LockoutMessage { get; set; }

/// <summary>Gets or sets the <c>LockoutStartDate</c>.</summary>
[Column, DataField( FieldName = "LockoutStartDate" )]
private DateTime? LockoutStartDateUTC { get; set; }

public DateTime? LockoutStartDate {
get { return ConvertToLocalTime( LockoutStartDateUTC ); }
set { LockoutStartDateUTC = ConvertToUniversalTime( value ); }
}

#endregion

#region Associations

private EntitySet<ApplicationMessage> messages;

[Association( Storage = "messages", OtherKey = "ApplicationId" )]
public EntitySet<ApplicationMessage> Messages {
get { return messages; }
set { messages.Assign( value ); }
}

#endregion

#region Methods

private void SendPropertyChanged( string propertyName ) {
if ( ( PropertyChanged != null ) ) {
PropertyChanged(
this,
new PropertyChangedEventArgs( propertyName )
);
}
}

private void SendPropertyChanging( string propertyName ) {
if ( ( PropertyChanging != null ) ) {
PropertyChanging(
this,
new PropertyChangingEventArgs( propertyName )
);
}
}

#endregion

#region Event handlers

private void Messages_OnAdd( ApplicationMessage message ) {
message.Application = this;
}

private void Messages_OnRemove( ApplicationMessage message ) {
message.Application = null;
}

#endregion

#region Constructors

public Applications() {
messages = new EntitySet<ApplicationMessage>(
Messages_OnAdd,
Messages_OnRemove
);
}

#endregion

#region INotifyPropertyChanged Members

public event PropertyChangedEventHandler PropertyChanged;

#endregion

#region INotifyPropertyChanging Members

public event PropertyChangingEventHandler PropertyChanging;

#endregion
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top