This week while working on a nice project i run into a blizzard error that i spent hours to figure it out.
I am sure if you landed in this page you have probably seen the same clean error:
“Unable to retrieve metadata for DavidZController.” or of course XyzWhateverController. .
public class DavidZ
{
public Guid Id { get; set; }
public string Title { get; set; }
public string Address { get; set; }
public string Country { get; set; }
public DateTime Date { get; set; }
}
- Here are the things to verify:
public JurisLandDbConText()
: base("jurislandConnection")
{
}
Make sure jurislandConnection is the connection string in your Config
In my case 1. does not apply.
JurisLandDbConText:
DbContext
Make sure that you have
public DbSet<DavidZ> DavidZs{ get; set; }
part of the defined classes.
One easy way is to also show the Output when you rebuild your project. Pay attention to the lines of warning. You may see that some dbContext does not contains definition of the entity.
For some reasons Visual studio was not smart enough to detect that missing entity in my Data context. It seems obvious but it is not. When you have a big project that evolve with a lot of entities, this error can happen very fast.
- The Last case you may get this is:In your entity class, you decorated with Serializable
[Serializable()]
public class DavidZ
: BaseEntity
{
Remove the decorator and you are good to go. B