2

How to add a additional field in the database schema(SQL) from NHibernate mapping exported that not exist on entity?

I have:

Property(x => x.Name, "Name");
Property(x => x.Description, "Product");

and I want add to exported schema(SQL):

Property("Department"); (this property not exist in the entity)
Fran
  • 6,440
  • 1
  • 23
  • 35
Cristian18
  • 220
  • 3
  • 12

2 Answers2

1

You should be able to use an AuxilliaryDatabaseObject.

David Osborne
  • 6,436
  • 1
  • 21
  • 35
0

I'm fairly certain that Nhibernate is not going to handle this scenario. Nhibernate can map to an existing database in a database first scenario or generate the schema in a domain first scenario. Nhibernate only knows about the database objects that you tell it about in the mapping. Since you've got extra fields on tables it sounds like you've got a database first scenario and should use something like database version software.

Fran
  • 6,440
  • 1
  • 23
  • 35
  • This field is updated by a sql function(and is not necessary in the entity). I can generate the SQL schema(script) to create the table but without the "Department" column. – Cristian18 Feb 01 '17 at 14:57
  • The only thing i can think of is to map it readonly, generated in you mapping, but your don't want to map it at all. – Fran Feb 01 '17 at 15:40
  • I just asking if it was possible, As I do not find much documentation, but I'll do it like this, thanks Fran. – Cristian18 Feb 01 '17 at 15:55