There is a group of friends said the official example, but the English and internet is too poor ... Think for yourself.
Recently developed projects, need to read some information from the external system, after the calculation into the local database, the external system directly provide the database to me. So a multi-database connection is needed locally.
Project using ABP Framework development, unfamiliar can look here
To start with, I already have a dbcontext in my project that inherits to Abpzerocommondbcontext, creates a new context, and I'm using Dbfirst to generate it directly from the database and then inherit it to Abpdbcontext. This is where I forgot to modify the inheritance directly inherited dbcontext the results of the whole day ... Then add the storage for that context to the repositories:
Public Abstract class articlerepository< TEntity, tprimarykey>: Efrepositorybase<sampledbcontext, TEntity, tprimarykey> where class ,ientity<tprimarykey> { protectedbase( Dbcontextprovider) { } }
The warehousing is not the same as the default warehousing Sampledbcontext is the context of other databases. This allows you to define the IRepository directly in the application, which can then be called directly in the method, as shown in the following example:
Private ReadOnly Irepository<article, system.guid> _articlerepository; Public Articlesappservice (irepository<article, guid> articlerepository) { = articlerepository ; }
Note Here the irepository<article, Guid>, the first parameter is ientity type, so you need to modify the definition of artice, I am directly inheriting entity<guid>
ABP connects multiple databases with different warehouses