views:

193

answers:

0

I've created the following classes and use the automap functionality of fluent to automatically generate my database:

public interface IBaseClass
    {
        int Id { get; set; }
        DateTime CreatedOn { get; set; }
    }

public interface IApplicant : IBaseClass 
    {
        string Firstname { get; set; }
        string Lastname { get; set; }
        string Email { get; set; }
        string Password { get; set; }
    }

I use NHibernate's GenerateSchemaCreationScript method to generate the DDL for BaseClass and Applicant.

Here's the DDL I get:

create table [BaseClass] (Id INT IDENTITY NOT NULL, 
       [CreatedOn] DATETIME null, 
       primary key (Id))
create table Applicant (BaseClassId INT not null, 
      [Firstname] NVARCHAR(255) null, 
      [Lastname] NVARCHAR(255) null, 
      [Email] NVARCHAR(255) null, 
      [Password] NVARCHAR(255) null, 
      primary key (BaseClassId))
alter table Applicant add constraint Applicant_BaseClass foreign key (BaseClassId) references [BaseClass]

My problem is that the the foreign key that is added to the Applicant table only references the BaseClass table and not the Column Id in this table. This is probably valid, but SQL Examiner (which I'm using to update my database) demands both the table and the column name in foreign key constraints.

My question is: Is there any way that I can force fluent/NHibernate to add the referenced column name to the foreign key constraint?