19
votes

We are using Entity Framework in our project and I have an entity that I built in my model. I then have a function import that uses a stored procedure. The method created by the function import is supposed to return a collection of the custom entity I created.

The problem is that I get an error when I build that says "The entity type 'someentity' is not mapped.

What does this mean? Is it upset because the entity does not have an underlying data store? It doesn't need one, the function import returns instances of this entity and I have no need to update, edit, or insert entities of this type.

The function import works great and returns a collection of my entity as desired, but this error is annoying. Though the error list lists it as a compile error, it does not actually stop the solution from compiling.

Update

If I open the EDMX in the XML editor and double click the error in the error list it highlights this chunk of XML in red:

   <EntityContainerMapping StorageEntityContainer="KlasEntitiesStoreContainer" CdmEntityContainer="KlasEntities">
      <EntitySetMapping Name="VendorBriefs"><EntityTypeMapping TypeName="KlasEntityDataModel.VendorBrief"><MappingFragment StoreEntitySet="ev_VendorBriefs">
        <ScalarProperty Name="VendorBriefID" ColumnName="VendorBriefID" />
        <ScalarProperty Name="Title" ColumnName="Title" />
        <ScalarProperty Name="Link" ColumnName="Link" />
        <ScalarProperty Name="LinkText" ColumnName="LinkText" />
        <ScalarProperty Name="BriefPath" ColumnName="BriefPath" />
        <ScalarProperty Name="Description" ColumnName="Description" />
        <ScalarProperty Name="IsActive" ColumnName="IsActive" />
        <ScalarProperty Name="DisplayOrder" ColumnName="DisplayOrder" />
      </MappingFragment></EntityTypeMapping></EntitySetMapping>
      <FunctionImportMapping FunctionImportName="SearchForVendorProductByKlasID" FunctionName="KlasEntities.Store.ev_ds_Products_SearchByKLASID" />
    </EntityContainerMapping>
5

5 Answers

10
votes

Each entity must be mapped either to QueryView or to database table / defining query. You can't create the entity which is not mapped at all. If you want to define result of function import which is not mapped in your model you must define your VendorBrief as complex type.

8
votes
  1. Open the datamodel (edmx file)
  2. Right-click in the datamodel and select Model Browser
  3. In the model browser window go to Function Imports and delete the appropriate items.
6
votes

Try to open your Entity file diagram, the .edmx. And then delete all the tables using DEL. And then right click inside the diagram and select Update Model from Database.

The Visual Studio is a little bugged in this stuff.

3
votes

Have you tried representing it using a Complex Type instead of an Entity and mapping to that instead?

http://msdn.microsoft.com/en-us/library/bb738472.aspx

-1
votes

I was having this issue as well but the error just went away when I opened the edmx in the XML editor. I tried all variations of removing tables then updating the edmx.

The other odd thing I was having, the error was referring to a relationship between two tables but when I double clicked on the error message it highlighted another table other than the two it was referring to.