views:

28

answers:

1

I have a EDM with a entity "Extensions" - within this object is the property extension. I've wired up all the other columns just fine, but this one refuses to wire up. I'm guessing because the entity and the property share the same name? Here is my code, the extensions doesn't work, the prefix does work:

Imports System.Web.DynamicData
Imports System.ComponentModel.DataAnnotations
<MetadataType(GetType(ExtensionsMetaData))> _
Partial Public Class Extensions

End Class
Public Class ExtensionsMetaData
Private _phones_extensions As Object
Private _prefix As Object
Private _did_flag As Object
Private _len As Object
Private _sfc_id As Object
Private _name_display As Object
Private _floor As Object
Private _room As Object
Private _phones_departments As Object
Private _phones_buildings As Object
Private _phones_phones As Object
Private _phones_restriction_classes As Object
Private _phones_tens As Object
<DisplayName("Extension")> _
Public Property extensions() As Object
    Get
        Return _phones_extensions
    End Get
    Set(ByVal value As Object)
        _phones_extensions = value
    End Set
End Property
<DisplayName("Prefix")> _
Public Property prefix As Object
    Get
        Return _prefix
    End Get
    Set(ByVal value As Object)
        _prefix = value
    End Set
End Property

End Class

How can I get this code to work? I've looked all through my data model and it looks like the name should be Extensions!

The error I am receiving is: The associated metadata type for type 'phoneDBentities.Extensions' contains the following unknown properties or fields: extensions. Please make sure that the names of these members match the names of the properties on the main type.

+2  A: 

This is a limitation of EF's "convention over configuration" feature.

Here's a related question: http://stackoverflow.com/questions/651312/entity-framework-mapping-oddity-member-names-cannot-be-the-same-as-their-enclos

The easiest way to fix the problem would be to rename the property to "PhoneExtension."

Dave Swersky
Thanks. Just what I needed.
davemackey