I have been doing some research into the fluent API to be able to make this but i am not sure if that is the way to go, from what i understand the OnModelCreate
will recreate a DB but what i actually need is a way to relate my tables for my entity, i have a DB with this 2 tables
dbo.Fleets
OwnerId (PK,uniqueidentifier,not null)
ownerName (nvarchar(255),not null)
dbo.UserAccount
UserID (PK,uniqueidentifier,not null)
UserName (nchar(20), null)
SelectedFleet (FK,uniqueidentifier,null)
PrimaryFleet (FK,UniqueIdentifier,null)
The foreign keys are for Fleets.OwnerId
, both of them, so inside my application i want to be able to get the fleet for my Primary and SelectedFleet
with EF
.
so if i run var v = dc.UserAccounts.Where(a => a.UserName == model.UserName).Include(d => d.Fleet).SingleOrDefault();
I'll be getting my complete results