Most probably the reason for the error you are getting is incorrect field name passed to the HasFieldName()
extension method. This method requires the name of the field which is accessed through the property specified in the HasProperty() method. So in your case you must pass the actual name of field accessed through the Id
Note that after fixing the field names, your code will still result in an error due to the fact that OpenAccess will search the fields of Contact and Address in the Customer class. You can however take advantage of our struct support
and define Address and Contact as structures. This is the OpenAccess ORM feature that matches the Entity Framework Complex Types support. I have attached a sample project illustrating how to map Customer class that has properties of types Address and Contact which are defined as structures. With this approach however, the Address and Contact objects will not be persistent, they will be used solely to organize the data contained within Customer objects. Please note that in order to run the project you will need to upgrade the project references
and change the connection strings located in both app.config files.
In case you wish to persist Address and Contact, you may try to organize your classes in a hierarchy and use Flat Inheritance
, with which all types in the hierarchy are mapped to the same table.
I hope the provided information will help you with your scenario.
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.