No mapping specified for the following EntitySet/AssociationSet

Today I was working on a new project using Entity Framework 4. This is the first time I have used the model first approach available with EF 4 and came across an interesting compiler error, 'No mapping specified for the following EntitySet/AssociationSet'. After that is listed several entities defined in my model. My first thought was it must be complaining about some of the associations I created between these entities. I had created many relationships just like I might designing my database tables first, so my thought was I had done something wrong.

So I searched for the error message using quotes. Side note: if you wrap your search term in quotes all the major search engines do a specific search for URLs containing that exact string. The only results I got back were relating to stored procedures, which I had none in my model. But I did find one secondary reference to an ASP.NET forum post on the error. The answer was not having the corresponding tables in my database yet. In other words I needed to Generate the Database from the Model.

So I did, which creates a SQL script, that must be executed. I am not sure why it wont just update the database for you, but I will deal with that later. I sort of can understand. So I executed the script, recompiled and viola the error has disappeared!

Share This Article With Your Friends!