Question

In NHibernate, there is a method doing something like ThisOrThat.VeryfyMappings() (I don't know the exact definition of it since it was a while ago I last tried NHibernate...)

I recall seeing a blog post somewhere where the author showed how to do some similar testing in Entity Framework 4, but now I cant find it. So, how do I test my EF4 Code-Only mappings?

Was it helpful?

Solution

You should be able to apply the same approach as described in this blog post. It describes how to do this for Fluent NHibernate, but it should be pretty much the same for EF4.

You'll need to implement the Validate(The)Mappings method yourself, and regardless of whether you use the repository approach or go directly through the context the basic idea is the same: insert an object and retrieve it using a second repository/context to verify that all fields have been correctly transferred. Additional checks will be needed to verify references.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top