We are using two database in that i need to inherit this model or entity table alone. For this how to specify database name for particular class or entity table in entity-frame work. It is possible?
Database Name: "Test1"
public class User : BaseEntity
{
public string Email { get; set; }
public string Password { get; set; }
}
now how to set this model as navigation property in another model. like,
Database Name: "Test2"
public class Test: BaseEntity
{
public int UserId { get; set; }
public virtual User User { get; set; }
}
public class BaseEntity
{
public int Id { get; set; }
}
Entity Framework
DbContextcould handle one Database.Then you should have two
DbContext‘s for your two Databases.Update :
I advice you not to do that. in another words you your Database and your Model should be in harmony “I love this word :)”
And anything beyond that I suppose it should be in Service class “Layer”.
So in your example you suppose to have a
UserServiceclass the get your User and don’t do this logic in theTestclass.One another thing to notice: If your model connected together like this way then you should have just one Database.