Forget the environment: NHibernate Version: 4.0.4.4000 Fluent NHibernate Version : 2.0.3.0 Sql Server 2014
On Wednesday, June 8, 2016 at 12:53:56 AM UTC+8, zhon...@gmail.com wrote: > > > > > Class definition: > > public class worker > { > public virtual float Balance { get; set; } > public virtual int? Age { get; set; } > public virtual string Name { get; set; } > public virtual Sex Sex { get; set; } > public virtual string HomeAddress { get; set; } > public virtual DateTime Birthday { get; set; } > public virtual int Id { get;} > public virtual byte[] Image { get; set; } > public virtual string Region { get; set; } > public virtual string City { get; set; } > } > > > > > > > Mapping: > > Map(w => w.Region) > .Column("WorkerRegion") > .CustomSqlType("char(6)") > .Not.Nullable().Index("WorkerRegion_Index"); > > > Map(w => w.City,"WorkerCity") > .CustomSqlType("nvarchar(26)") > .Formula("WorkerRegion"); > > > Configuration: > > internal static class NhibernateHelper > { > private static readonly Lazy<ISessionFactory> SessionFactory=new > Lazy<ISessionFactory>(GetSessionFactory,LazyThreadSafetyMode.ExecutionAndPublication); > private const string ConnectionStringKey = "FNHDemo"; > > private static ISessionFactory GetSessionFactory() > { > var sessionFactory = Fluently.Configure() > .Database(MsSqlConfiguration.MsSql2012.ConnectionString(c => > c.FromConnectionStringWithKey(ConnectionStringKey))) > .Mappings(m => > m.FluentMappings.AddFromAssembly(typeof(NhibernateHelper).Assembly)) > .ExposeConfiguration(BuildSchema) > .BuildSessionFactory(); > return sessionFactory; > } > public static ISession GetSession() > { > return SessionFactory.Value.OpenSession(); > } > > public static void BuildSchema(Configuration cfg) > { > new SchemaExport(cfg).Create(true, true); > } > } > > > > Generated Schema Script: > > create table Worker ( > WorkerId int IDENTITY NOT NULL, > WorkerBalance decimal(9,4) not null, > WorkerAge tinyint default Month(GetDate()) null, > WorkerBirthday date not null, > WorkerRegion char(6) not null, > WorkerCity nvarchar(26) null, > WorkerSex nvarchar(10) default 'Male' null, > WorkerName nvarchar(4) not null, > WorkerImage binary(2000) null, > primary key (WorkerId) > ) > > create index WorkerRegion_Index on Worker (WorkerRegion) > > create index WorkerName_Index on Worker (WorkerName) > > > > Everything seems fine except the WorkerCity Column, never become a > computed column, frustrating, any help will be appreciated. > > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibernate+unsubscr...@googlegroups.com. To post to this group, send email to fluent-nhibernate@googlegroups.com. Visit this group at https://groups.google.com/group/fluent-nhibernate. For more options, visit https://groups.google.com/d/optout.