Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity framework error "Entity type is not mapped."

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>
like image 995
Chev Avatar asked Apr 20 '11 23:04

Chev


1 Answers

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.

like image 113
Ladislav Mrnka Avatar answered Sep 21 '22 18:09

Ladislav Mrnka