Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6252905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:53:28+00:00 2026-05-24T13:53:28+00:00

Hi I have an object called document and one called user Document public virtual

  • 0

Hi I have an object called document and one called user

Document

    public virtual string Name { get; set; }
    public virtual string Description { get; set; }
    public virtual User User { get; set; }

Documentmap

    public DocumentMap()
    {
        Map(x => x.Name);
        Map(x => x.Description);
        References(x => x.User);
    }

User

    public virtual string UserId { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string MiddleInitial { get; set; }
    public virtual string LastName { get; set; }
    private readonly IList<Document> _documents = new List<Document>();
    public virtual IEnumerable<Document> Documents { get { return _documents; } }
    public virtual void Remove(Document document)
    {
        _documents.Remove(document);
    }
    public virtual void Add(Document document)
    {
        if (!document.IsNew() && _documents.Contains(document)) return;
        _documents.Add(document);
    }

    Map(x => x.UserId);
        Map(x => x.FirstName);
        Map(x => x.MiddleInitial);
        Map(x => x.LastName);
        HasMany(x => x.Documents).Access.CamelCaseField(Prefix.Underscore); 

Pretty straighforward ( they inherit from base class with stuff like createddate modifieddate etc )

when I try to get all doc by userid I get this

Invalid column name ‘UserId’.

the column most definitely is in the table. It also lists several of the base class items as not being there.

I take the sql and past it in query manager and I get intellisense saying they are invalid columns. I run it and it executes just fine. Further more there are plenty of other objects using these base classes with no problems.

I have tried various things like explicitly mapping the key name, the column name using inverse etc to no avail. Don’t really know what to do.
Thanks,
Raif

//EDIT as per request sorry it’s so verbose. the database is created by nhibernate create schema

Document

public class Document : Entity
{
    public virtual string Name { get; set; }
    public virtual string Description { get; set; }
    public virtual DocumentCategory DocumentCategory { get; set; }
    [ValueOf(typeof(DocumentFileType))]
    public virtual string FileType { get; set; }
    public virtual string FileUrl { get; set; }
    public virtual int? Pages { get; set; }
    public virtual decimal? Size { get; set; }
    public virtual User User { get; set; }
}

public class DocumentMap : EntityMap<Document>
{
    public DocumentMap()
    {
        Map(x => x.Name);
        Map(x => x.Description);
        Map(x => x.FileUrl);
        Map(x => x.Pages);
        Map(x => x.Size);
        Map(x => x.FileType);
        References(x => x.DocumentCategory);
        References(x => x.User);
    }
}

Entity

public class Entity : IGridEnabledClass, IEquatable<Entity>
{
    public virtual int EntityId { get; set; }
    public virtual DateTime? CreateDate { get; set; }
    public virtual DateTime? ChangeDate { get; set; }
    public virtual int ChangedBy { get; set; }
    public virtual bool Archived { get; set; }

    public virtual bool IsNew()
    {
        return EntityId == 0;
    }

User

 public class User : DomainEntity, IUser
{
    public virtual string UserId { get; set; }
    [ValidateNonEmpty]
    public virtual string FirstName { get; set; }
    public virtual string MiddleInitial { get; set; }
    [ValidateNonEmpty]
    public virtual string LastName { get; set; }
    public virtual string Title { get; set; }
    public virtual DateTime? BirthDate { get; set; }
    public virtual string StartPage { get; set; }
    public virtual UserLoginInfo UserLoginInfo { get; set; }
    public virtual UserStatus UserStatus { get; set; }
    public virtual Photo HeadShot { get; set; }
    private readonly IList<Document> _documents = new List<Document>();
    public virtual IEnumerable<Document> Documents { get { return _documents; } }
    public virtual void Remove(Document document)
    {
        _documents.Remove(document);
    }
    public virtual void Add(Document document)
    {
        if (!document.IsNew() && _documents.Contains(document)) return;
        _documents.Add(document);
    }
    several more collections

public class UserMap : DomainEntityMap<User>
{
    public UserMap()
    {
        Map(x => x.UserId);
        Map(x => x.FirstName);
        Map(x => x.MiddleInitial);
        Map(x => x.LastName);
        Map(x => x.BirthDate);
        Map(x => x.StartPage);
        References(x => x.UserStatus);
        References(x => x.UserLoginInfo);
        References(x => x.HeadShot);
        HasMany(x => x.Documents).Access.CamelCaseField(Prefix.Underscore); 

database tables create from script select to menu item on management studio

  SELECT [EntityId]
  ,[CreateDate]
  ,[ChangeDate]
  ,[ChangedBy]
  ,[Archived]
  ,[Name]
  ,[Description]
  ,[FileUrl]
  ,[Pages]
  ,[Size]
  ,[FileType]
  ,[DocumentCategoryId]
  ,[UserId]
  FROM [DecisionCriticalSuite].[dbo].[Document]
 GO


  SELECT [EntityId]
  ,[CreateDate]
  ,[ChangeDate]
  ,[ChangedBy]
  ,[Archived]
  ,[TenantId]
  ,[OrgId]
  ,[UserId]
  ,[FirstName]
  ,[MiddleInitial]
  ,[LastName]
  ,[BirthDate]
  ,[StartPage]
  ,[UserStatusId]
  ,[UserLoginInfoId]
  ,[HeadShotId]
  ,[OrganizationId]
  FROM [DecisionCriticalSuite].[dbo].[User]
  GO

error from nhprof

ERROR: 
Invalid column name 'UserId'.
Invalid column name 'UserId'.
Invalid column name 'EntityId'.
Invalid column name 'EntityId'.
Invalid column name 'CreateDate'.
Invalid column name 'ChangeDate'.
Invalid column name 'ChangedBy'.
Invalid column name 'Archived'.
Invalid column name 'FileType'.
Invalid column name 'UserId'.Could not execute query: SELECT documents0_.UserId as UserId1_, documents0_.EntityId as EntityId1_, documents0_.EntityId as EntityId49_0_, documents0_.CreateDate as CreateDate49_0_, documents0_.ChangeDate as ChangeDate49_0_, documents0_.ChangedBy as ChangedBy49_0_, documents0_.Archived as Archived49_0_, documents0_.Name as Name49_0_, documents0_.Description as Descript7_49_0_, documents0_.FileUrl as FileUrl49_0_, documents0_.Pages as Pages49_0_, documents0_.Size as Size49_0_, documents0_.FileType as FileType49_0_, documents0_.DocumentCategoryId as Documen12_49_0_, documents0_.UserId as UserId49_0_ FROM [Document] documents0_ WHERE           documents0_.UserId=@p0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:53:30+00:00Added an answer on May 24, 2026 at 1:53 pm

    Make sure nhibernate is querying against the same database as what you are querying against in sql management studio.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey. I have an object that has a string property called BackgroundColor. This string
I have a silverlight user control which is bound to a Document object. the
I have a collection of an object called Bookmarks which is made up of
I have a c# object with a property called Gender which is declared as
I have a property called IsSecureConnection that is part of my object's interface. This
One thing I have continually found very confusing about using an object database like
i have two files one called stats.js one called storage.html in stats.js in contains
I have one file called test.ai and I need to print it several times,
I have an object that has just one member with a property of type
I have a json object retrieved from server in my $(document).ready(...); that has an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.