You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Country
{
public virtual int Id { get; protected set; }
public virtual string Code { get; protected set; }
public virtual string Name { get; protected set; }
}
The "Code" property is actually unique so I thought to use it as natural id. But I wanted to specify the length of it. So I've created this map:
I have a similar problem. After having specifiec .UseOverridesFromAssemblyOf I am then using IAutoMappingOverride. When trying to specify that a string column is a NaturalId.ReadOnly I get the same error.
It occurred to me to try using IgnoreProperty in the Override first...
This seems to prevent the error message (though the .ReadOnly() still seems not to be having the expected effect - CustomerCode column is still nullable)
public class CustomerConfigOverride: IAutoMappingOverride<Customer>
{
public void Override(AutoMapping<Customer> mapping)
{
mapping.Schema("MySchema");
mapping.IgnoreProperty(c => c.CustomerCode);
mapping.NaturalId()
.Property(c => c.CustomerCode)
.ReadOnly();
...
I want to map this simple class:
The "Code" property is actually unique so I thought to use it as natural id. But I wanted to specify the length of it. So I've created this map:
And I got this exception:
NHibernate.MappingException: Duplicate property mapping of Code found in Domain.Model.Geo.Country
The resulting HBM is this:
Packages I use:
The text was updated successfully, but these errors were encountered: