Skip to content

EF Mapping with POCO Errors

September 22, 2011

If you ever receive the following error messaging containing this wording “Mapping and metadata information could not be found for EntityType”, it is a rather anonymous message saying that in the Model folder of the EF mappings in the .edmx file, something has gone wrong in the mappings of the XML somewhere.

For anyone else dealing with the error,  it’s clearly stating the likely scenarios which I’ve found that cause this (extremely unhelpful) error:

  • Misspelled properties (case-sensitive!) This is the most likely problem, if somewhere in your model fields/attributes are missing to the conceptual model of your database, Visual Studio will complain like nobody’s business, make sure all fields/attributes/variables right down to the types match correctly. E.g.

    <EntityType Name=”test”>
        <PropertyRef Name=”testID” />
        <PropertyRef Name=”secondtestID” />
      <Property Type=”String” Name=”test” Nullable=”false” MaxLength=”16″ FixedLength=”true” Unicode=”false” />
      <Property Type=”Int32″ Name=”secondtestID” Nullable=”false” />
      <Property Type=”String” Name=”CLI” MaxLength=”25″ FixedLength=”true” Unicode=”false” />
      <Property Type=”DateTime” Name=”ReceivedTime” />
      <Property Type=”String” Name=”testparam” MaxLength=”100″ FixedLength=”true” Unicode=”false” />
      <Property Type=”Boolean” Name=”testbool” />

    This has got to match with the variables in the model class of your web service.

  • Properties missing in the POCO class. (You need to write everything down correctly!) This also includes things lime Nullable=”false” for keys, you need to include this otherwise it won’t work.
  • Type mismatches between the POCO and entity-type (e.g., int 32 instead of long)
  • Enums in the POCO (EF doesn’t support enums right now, so don’t include them)

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: