This is because of the way EF4 works with model-first.
When you first create a model-first model, it's in a state that the SSDL does not exist. You can drag entities, associate them and so forth and yet, if you take a look at the SSDL on the EDMX file, you will see that none of the entities have an associated storage table in the SSDL.
That changes when you click the
Generate Database From Model context menu item. The confusing part is that this action does more than simply generating a DDL script. In fact, it changes the EDMX file to include SSDL information. From this point on, the EDMX file will enter a state in which every entity in the designer/CSDL must map to an entity in the SSDL. If one does not map, it will trigger a compile time error:
No mapping specified for the following EntitySet/AssociationSet - (EntityName)
Another interesting fact is that it's not the kind of error that will prevent compilation. It will, indeed, generate the output class library. Shouldn't it be a warning or something?
To prevent this error, All you have to do after inserting a new entity is to
Generate Database From Model again. That will update the SSDL and fix the mappings.
If you are not using model-first and you "update from database", you will also have this error in the case you deleted a table in DB Server. This is because Entity Framework will not automatically delete the entity for you. Delete the entity manually and the error will go away.
~ Answered on 2011-04-14 18:22:32