I create my table like:
CREATE TABLE [dbo].[Users](
Id int NOT NULL IDENTITY (1,1) PRIMARY KEY,
EmailAddress varchar(255),
FullName varchar(255),
Password varchar(255),
);
My model is:
public class UserModel : Entity
{
public virtual string EmailAddress { get; set; }
public virtual string FullName { get; set; }
public virtual string Password { get; set; }
}
My entity class is:
public abstract class Entity
{
public virtual int Id { get; set; }
}
My mapping class is simple as below:
public class UserModelMap : ClassMap<UserModel>
{
public UserModelMap()
{
Table("Users");
Id(x => x.Id);
Map(x => x.EmailAddress);
Map(x => x.FullName);
Map(x => x.Password);
}
}
And i include all my classes the have to be mapped using this following configuraiton:
private static void InitializeSessionFactory()
{
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey("DefalutConnection"))
)
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<Entity>())
.ExposeConfiguration(cfg => new SchemaExport(cfg)
.Create(true, true))
.BuildSessionFactory();
}
But when i query my database using the following code:
Session.Query<TEntity>();
Where TEntityis my user model i get no rows back from the database.
I cant seem to work out what the issue is here.