I have a Consumer class and a BillableConsumer : Consumer class. When trying to do any operation on my "Consumers" set, I get the error message "Object mapping could not be found for Type with identity Models.BillableConsumer.
From the CSDL:
<EntityType Name="BillableConsumer" BaseType="Models.Consumer">
<Property Type="String" Name="CardExpiratoin" Nullable="false" />
<Property Type="String" Name="CardNumber" Nullable="false" />
<Property Type="String" Name="City" Nullable="false" />
<Property Type="String" Name="Country" Nullable="false" />
<Property Type="String" Name="CVV" Nullable="false" />
<Property Type="String" Name="NameOnCard" Nullable="false" />
<Property Type="String" Name="PostalCode" Nullable="false" />
<Property Type="String" Name="State" />
<Property Type="String" Name="StreetAddress" Nullable="false" />
</EntityType>
From the C-S:
<EntitySetMapping Name="Consumers开发者_开发问答">
<EntityTypeMapping TypeName="IsTypeOf(Models.Consumer)">
<MappingFragment StoreEntitySet="consumer">
<ScalarProperty Name="LoginID" ColumnName="LoginID" />
<ScalarProperty Name="FirstName" ColumnName="FirstName" />
<ScalarProperty Name="LastName" ColumnName="LastName" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(Models.BillableConsumer)">
<MappingFragment StoreEntitySet="billinginformation">
<ScalarProperty Name="CardExpiratoin" ColumnName="CardExpiratoin" />
<ScalarProperty Name="CardNumber" ColumnName="CardNumber" />
<ScalarProperty Name="City" ColumnName="City" />
<ScalarProperty Name="Country" ColumnName="Country" />
<ScalarProperty Name="CVV" ColumnName="CVV" />
<ScalarProperty Name="LoginID" ColumnName="LoginID" />
<ScalarProperty Name="NameOnCard" ColumnName="NameOnCard" />
<ScalarProperty Name="PostalCode" ColumnName="PostalCode" />
<ScalarProperty Name="State" ColumnName="State" />
<ScalarProperty Name="StreetAddress" ColumnName="StreetAddress" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
Is this because I did not specifically add the BillableConsumer entity to the object set? How do I do that in a POCO scenario?
If you notice in my CSDL there is a column called "CardExpiratoin" (spelling mistake in DB column name). Of course my class which was hand-coded did not have this spelling mistake.
The way I found the problem is by generating POCOs from the T4 template, seeing it worked, and working my way back from there. Hope this helps anyone with the same problem. I also wish the error was a bit clearer to begin with.
I was experiencing this problem as well, and in my case it was also because of an error in a hand written POCO class. In most of the cases, you get an informational error messages, but as it seems in some rare cases you get something vague like 'Object mapping could not be found'.
In my particular case, there were columns of type VARCHAR(1) in the database, which I incorrectly mapped to char. I didn't try char?, but mapping to string certainly resolved the problem.
精彩评论