I have database ObjectTypes with the (id,…).
I want in my model (EF 4) to add refference from my database in some table foreign key to refference to objectTypes.dbo.ObjectTypes field. How can I do that?
public class KOATUUContext : DbContext
{
static KOATUUContext()
{
Database.SetInitializer<KOATUUContext>(null);
}
public KOATUUContext()
: base("KOATUU")
{
}
public DbSet<KOATUU> KOATUUs { get; set; }
public DbSet<Region> Regions { get; set; }
public DbSet<TerType> TerTypes { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new KOATUUMap());
modelBuilder.Configurations.Add(new RegionMap());
modelBuilder.Configurations.Add(new TerTypeMap());
base.OnModelCreating(modelBuilder);
}
}
I thought this was not possible as well, but this post seems to discuss the same problem with a working solution:
Making an Entity Framework Model span multiple databases