Nhibernate added duplicate column on insert

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Nhibernate added duplicate column on insert



I'm using Fluent NHibernate. I have a class called Audit which has ItemID property. Everytime that I want to save anything in that table give me this error.



Error message:
The column name 'itemid' is specified more than once in the SET clause or column list of an INSERT. A column cannot be assigned more than one value in the same clause. Modify the clause to make sure that a column is updated only once. If this statement updates or inserts columns into a view, column aliasing can conceal the duplication in your code.



Classes


public class Audit : EntityBase
{
/*********
** Accessors
*********/
/// <summary>When the action was logged.</summary>
public virtual DateTime Date { get; set; }

/// <summary>The person who triggered the action.</summary>
public virtual BasicUser User { get; set; }

/// <summary>The name of the related group, used for filtering (e.g. idea, system-settings, site-editor)</summary>
public virtual string ItemGroup { get; set; }

/// <summary>The ID of the related entity.</summary>
public virtual int ItemID { get; set; }

/// <summary>The title of the related entity.</summary>
public virtual LocalizableString ItemTitle { get; set; }

/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public Audit() { }
}



Mapping:


public class AuditMapper<T> : IEntityMapper<T>
where T : Audit
{
public virtual void ExtendDomainModel(IEntityMetadata<T> metadata)
{
metadata.MapTablePerClassHierarchy<Audit, T>("`ItemGroup`");

if (!metadata.IsSubclass)
{
metadata.Map.ManyToOne(entity => entity.User, relation => relation.Column("`userid`"));
metadata.Map.MapPropertyWithoutSaveConsideration(c => c.ItemGroup);
metadata.Map.Property(c => c.ItemID, mapper => mapper.Column("itemid"));
}
else
{
metadata.MapSubclass.ManyToOne(entity => entity.User, relation => relation.Column("`userid`"));
metadata.MapSubclass.MapPropertyWithoutSaveConsideration(c => c.ItemGroup);
metadata.MapSubclass.MapPropertyWithoutSaveConsideration(c => c.ItemID);
}
}
}



SQL Query:



INSERT INTO [brainbank].[idealink.core.audit] ([date], [userid], itemid, [itemtitle_key], [itemtitle_original], [itemid], [ItemGroup]) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, 'IdeaAudit'); select SCOPE_IDENTITY()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived