Is it possible to match the one-to-one relationship using the parent key and the discriminator value? I know that this code at first does not like the discriminator property in a particular class and refers only to the Map method.
FlightTypes { Inbound = 1, Outbound = 2} public class Transaction - int TransactionId - int? InboundFlightId - InboundTransactionFlight InboundFlight - int? OutboundFlightId - OutboundTransactionFlight OutboundFlight public abstract class TransactionFlight - TransactionFlightId public class InboundTransactionFlight : Flight - List<Transaction> InboundFor public class OutboundTransactionFlight : Flight - List<Transaction> OutboundFor Entity<InboundTransactionFlight>().Map(m => m.Requires("FlightTypeId").HasValue(1)); Entity<OutboundTransactionFlight>().Map(m => m.Requires("FlightTypeId").HasValue(2));
/ * this is what is currently created * /
CREATE TABLE Transactions ( TransactionId int NOT NULL, InboundFlightId int NULL, OutboundFlightId int NULL ) CREATE TABLE TransactionFlights ( TransactionFlightId int NOT NULL, FlightTypeId int NOT NULL, ... CONSTRAINT PK_TransactionFlights PRIMARY KEY CLUSTERED ( TransactionFlightId ) )
/ * is it possible to create / display this and keep the inheritance? * /
CREATE TABLE Transactions ( TransactionId int NOT NULL, ) CREATE TABLE TransactionFlights ( TransactionId int NOT NULL, FlightTypeId int NOT NULL, ... CONSTRAINT PK_TransactionFlights PRIMARY KEY CLUSTERED ( TransactionId, FlightTypeId ) )
Thanks.
source share