Browse Source

Merge branch 'dev' of https://github.com/volosoft/abp into dev

pull/2542/head
Yunus Emre Kalkan 7 years ago
parent
commit
493f5a7018
  1. 2
      docs/en/Best-Practices/Index.md
  2. 67
      docs/en/Connection-Strings.md
  3. 8
      docs/en/Data-Access.md
  4. 41
      docs/en/docs-nav.json
  5. 2
      modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj
  6. 1
      modules/blogging/app/update-database.ps1
  7. 2
      npm/ng-packs/package.json
  8. 4
      npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts
  9. 2
      npm/ng-packs/scripts/build.ts
  10. 4
      npm/ng-packs/scripts/index.js
  11. 1
      npm/ng-packs/scripts/install-new-dependencies.ts
  12. 1382
      npm/ng-packs/scripts/package-lock.json
  13. 19
      npm/ng-packs/scripts/package.json
  14. 1
      npm/ng-packs/scripts/prod-build.ts
  15. 1
      npm/ng-packs/scripts/publish.ts
  16. 0
      npm/ng-packs/scripts/push.ts
  17. 9
      npm/ng-packs/scripts/sync.ts
  18. 16
      npm/ng-packs/scripts/tsconfig.json
  19. 1193
      npm/ng-packs/scripts/yarn.lock

2
docs/en/Best-Practices/Index.md

@ -23,5 +23,5 @@ Also, this guide is mostly usable for general **application development**.
* [Data Transfer Objects](Data-Transfer-Objects.md)
* Data Access
* [Entity Framework Core Integration](Entity-Framework-Core-Integration.md)
* [MongoDB Integration](MongoDB-Integration.md)
* [MongoDB Integration](MongoDB-Integration.md)

67
docs/en/Connection-Strings.md

@ -1,11 +1,64 @@
# Data Access
# Connection Strings
ABP framework was designed as database agnostic, it can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions.
ABP Framework is designed to be [modular](Module-Development-Basics.md), [microservice compatible](Microservice-Architecture.md) and [multi-tenancy](Multi-Tenancy.md) aware. Connection string management is also designed to support these scenarios;
However, currently the following providers are implements:
* Allows to set separate connection strings for every module, so every module can have its own physical database. Modules even might be configured to use different DBMSs.
* Allows to set separate connection string and use a separate database per tenant (in a SaaS application).
* [Entity Framework Core](Entity-Framework-Core.md) (works with [various DBMS and providers](https://docs.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli).)
* [MongoDB](MongoDB.md)
* [Dapper](Dapper.md)
It also supports hybrid scenarios;
More providers might be added in the next releases.
* Allows to group modules into databases (all modules into a single shared database, 2 modules to database A, 3 modules to database B, 1 module to database C and rest of the modules to database D... etc.)
* Allows to group tenants into databases, just like the modules.
* Allows to separate databases per tenant per module (which might be harder to maintain for you because of too many databases, but the ABP framework supports it).
All the [pre-built application modules](Modules/Index.md) are designed to be compatible these scenarios.
## Configure the Connection Strings
See the following configuration:
````json
"ConnectionStrings": {
"Default": "Server=localhost;Database=MyMainDb;Trusted_Connection=True;",
"AbpIdentityServer": "Server=localhost;Database=MyIdsDb;Trusted_Connection=True;",
"AbpPermissionManagement": "Server=localhost;Database=MyPermissionDb;Trusted_Connection=True;"
}
````
> ABP uses the `IConfiguration` service to get the application configuration. While the simplest way to write configuration into the `appsettings.json` file, it is not limited to this file. You can use environment variables, user secrets, Azure Key Vault... etc. See the [configuration](Configuration.md) document for more.
This configuration defines three different connection strings:
* `MyMainDb` (the `Default` connection string) is the main connection string of the application. If you don't specify a connection string for a module, it fallbacks to the `Default` connection string. The [application startup template](Startup-Templates/Application.md) is configured to use a single connection string, so all the modules uses a single shared database.
* `MyIdsDb` is used by the [IdentityServer](Modules/IdentityServer.md) module.
* `MyPermissionDb` is used by the [Permission Management](Modules/Permission-Management.md) module.
[Pre-built application modules](Modules/Index.md) define constants for the connection string names. For example, the IdentityServer module defines a ` ConnectionStringName ` constant in the ` AbpIdentityServerDbProperties ` class (located in the ` Volo.Abp.IdentityServer ` namespace). Other modules similarly define constants, so you can investigate the connection string name.
## Set the Connection String Name
A module typically has a unique connection string name associated to its `DbContext` class using the `ConnectionStringName` attribute. Example:
````csharp
[ConnectionStringName("AbpIdentityServer")]
public class IdentityServerDbContext
: AbpDbContext<IdentityServerDbContext>, IIdentityServerDbContext
{
}
````
For [Entity Framework Core](Entity-Framework-Core.md) and [MongoDB](MongoDB.md), write this to your `DbContext` class (and the interface if it has).
> If you are developing a reusable, database provider independent module see also [the best practices guide](Best-Practices/Index.md).
## Database Migrations for the Entity Framework Core
Relational databases require to create the database and the database schema (tables, views... etc.) before using it.
The startup template (with EF Core ORM) comes with a single database and a `.EntityFrameworkCore.DbMigrations` project that contains the migration files for that database. This project mainly defines a *YourProjectName*MigrationsDbContext that calls the `Configure...()` methods of the used modules, like `builder.ConfigurePermissionManagement()`.
Once you want to separate a module's database, you typically will need to create a second migration path. The easiest way to create a copy of the `.EntityFrameworkCore.DbMigrations` project with the `DbContext` inside it, change its content to only call the `Configure...()` methods of the modules needs to be stored in the second database and re-create the initial migration. In this case, you also need to change the `.DbMigrator` application to be able to work with these second database too. In this way, you will have a separate migrations DbContext per database.
## Multi-Tenancy
See [the multi-tenancy document](Multi-Tenancy.md) to learn how to use separate databases for tenants.

8
docs/en/Data-Access.md

@ -1,9 +1,15 @@
# Data Access
## Database Providers
ABP framework was designed as database agnostic. It can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions. However, currently the following providers are implemented:
* [Entity Framework Core](Entity-Framework-Core.md) (works with [various DBMS and providers](https://docs.microsoft.com/en-us/ef/core/providers/).)
* [MongoDB](MongoDB.md)
* [Dapper](Dapper.md)
More providers will be added in the future.
More providers will be added in the future.
## See Also
* [Connection Strings](Connection-Strings.md)

41
docs/en/docs-nav.json

@ -257,29 +257,38 @@
},
{
"text": "Data Access",
"path": "Data-Access.md",
"path": "Data-Access.md",
"items": [
{
"text": "Entity Framework Core Integration",
"path": "Entity-Framework-Core.md",
"text": "Connection Strings",
"path": "Connection-Strings.md"
},
{
"text": "Database Providers",
"items": [
{
"text": "Switch to MySQL",
"path": "Entity-Framework-Core-MySQL.md"
"text": "Entity Framework Core",
"path": "Entity-Framework-Core.md",
"items": [
{
"text": "Switch to MySQL",
"path": "Entity-Framework-Core-MySQL.md"
},
{
"text": "Switch to PostgreSQL",
"path": "Entity-Framework-Core-PostgreSQL.md"
}
]
},
{
"text": "Switch to PostgreSQL",
"path": "Entity-Framework-Core-PostgreSQL.md"
{
"text": "MongoDB",
"path": "MongoDB.md"
},
{
"text": "Dapper",
"path": "Dapper.md"
}
]
},
{
"text": "MongoDB Integration",
"path": "MongoDB.md"
},
{
"text": "Dapper Integration",
"path": "Dapper.md"
}
]
},

2
modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj

@ -15,6 +15,8 @@
<PackageReference Include="Serilog.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0"/>
</ItemGroup>
<ItemGroup>

1
modules/blogging/app/update-database.ps1

@ -0,0 +1 @@
dotnet ef database update -s Volo.BloggingTestApp/Volo.BloggingTestApp.csproj -p Volo.BloggingTestApp.EntityFrameworkCore/Volo.BloggingTestApp.EntityFrameworkCore.csproj

2
npm/ng-packs/package.json

@ -12,7 +12,7 @@
"test": "ng test --watchAll --runInBand",
"commit": "git-cz",
"lint": "ng lint",
"scripts:build": "cd scripts && npm install && yarn build",
"scripts:build": "cd scripts && yarn && yarn build",
"prepare:workspace": "yarn scripts:build",
"ci": "yarn prepare:workspace && yarn ci:test && yarn ng lint && yarn ci:build",
"ci:test": "ng test --coverage=false",

4
npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts

@ -48,8 +48,8 @@ export default `
position: fixed;
top: 0;
left: 0;
width: calc(100% - 7px);
height: 100%;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.6);
z-index: 1040;
}

2
npm/ng-packs/scripts/build.js → npm/ng-packs/scripts/build.ts

@ -1,6 +1,4 @@
// ESM syntax is supported.
import execa from 'execa';
import fse from 'fs-extra';
import program from 'commander';
(async () => {

4
npm/ng-packs/scripts/index.js

@ -1,4 +0,0 @@
// Set options as a parameter, environment variable, or rc file.
// eslint-disable-next-line no-global-assign
require = require('esm')(module /* , options */);
module.exports = require('./main.js');

1
npm/ng-packs/scripts/install-new-dependencies.js → npm/ng-packs/scripts/install-new-dependencies.ts

@ -1,4 +1,3 @@
// ESM syntax is supported.
import execa from 'execa';
import fse from 'fs-extra';

1382
npm/ng-packs/scripts/package-lock.json

File diff suppressed because it is too large

19
npm/ng-packs/scripts/package.json

@ -3,14 +3,12 @@
"version": "1.0.0",
"description": "ABP helper scripts",
"main": "index.js",
"modules": "[build.js, sync.js]",
"scripts": {
"build": "node -r esm build.js",
"build:prod": "node -r esm prod-build.js",
"publish-packages": "node -r esm publish.js",
"install-new-dependencies": "node -r esm install-new-dependencies.js",
"sync": "node -r esm sync.js",
"test": "echo \"Error: no test specified\" && exit 1"
"build": "ts-node -r tsconfig-paths/register build.ts",
"build:prod": "ts-node -r tsconfig-paths/register prod-build.ts",
"publish-packages": "ts-node -r tsconfig-paths/register publish.ts",
"install-new-dependencies": "ts-node -r tsconfig-paths/register install-new-dependencies.ts",
"sync": "ts-node -r tsconfig-paths/register sync.ts"
},
"author": "",
"dependencies": {
@ -18,9 +16,12 @@
"commander": "^4.0.1",
"execa": "^2.0.3",
"fs-extra": "^8.1.0",
"prompt-confirm": "^2.0.4"
"prompt-confirm": "^2.0.4",
"typescript": "^3.7.4"
},
"devDependencies": {
"esm": "^3.2.25"
"esm": "^3.2.25",
"ts-node": "^8.5.4",
"tsconfig-paths": "^3.9.0"
}
}

1
npm/ng-packs/scripts/prod-build.js → npm/ng-packs/scripts/prod-build.ts

@ -1,4 +1,3 @@
// ESM syntax is supported.
import execa from 'execa';
import fse from 'fs-extra';

1
npm/ng-packs/scripts/publish.js → npm/ng-packs/scripts/publish.ts

@ -1,4 +1,3 @@
// ESM syntax is supported.
import execa from 'execa';
import fse from 'fs-extra';

0
npm/ng-packs/scripts/push.js → npm/ng-packs/scripts/push.ts

9
npm/ng-packs/scripts/sync.js → npm/ng-packs/scripts/sync.ts

@ -1,4 +1,3 @@
// ESM syntax is supported.
import fse from 'fs-extra';
import execa from 'execa';
@ -8,7 +7,9 @@ import execa from 'execa';
for (let i = 0; i < projectNames.length; i++) {
const project = projectNames[i];
const { dependencies: distDependencies, version } = await fse.readJson(`../dist/${project}/package.json`);
const { dependencies: distDependencies, version } = await fse.readJson(
`../dist/${project}/package.json`,
);
const srcPackagePath = `../packages/${project}/package.json`;
const srcPackage = await fse.readJson(srcPackagePath);
@ -25,7 +26,9 @@ import execa from 'execa';
try {
await execa('git', ['add', '../packages/*', '../package.json'], { stdout: 'inherit' });
await execa('git', ['commit', '-m', 'Update source packages versions', '--no-verify'], { stdout: 'inherit' });
await execa('git', ['commit', '-m', 'Update source packages versions', '--no-verify'], {
stdout: 'inherit',
});
} catch (error) {
console.error(error.stderr);
}

16
npm/ng-packs/scripts/tsconfig.json

@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"esModuleInterop": true
},
"exclude": ["node_modules", "dist"]
}

1193
npm/ng-packs/scripts/yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save