-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RevEng: Add DatabaseModelFactoryOptions
Also adds an abstract base class for IDatabaseModelFactory Resolves #14602
- Loading branch information
Showing
13 changed files
with
110 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Data.Common; | ||
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Scaffolding | ||
{ | ||
/// <summary> | ||
/// Base class used by database providers to reverse engineer a database into a <see cref="DatabaseModel" />. | ||
/// </summary> | ||
public abstract class DatabaseModelFactory : IDatabaseModelFactory | ||
{ | ||
/// <summary> | ||
/// Connects to the database using the given connection string and creates a <see cref="DatabaseModel" /> | ||
/// for the database. | ||
/// </summary> | ||
/// <param name="connectionString"> The connection string for the database to reverse engineer. </param> | ||
/// <param name="options"> The options specifying which metadata to read. </param> | ||
/// <returns> The database model. </returns> | ||
public abstract DatabaseModel Create(string connectionString, DatabaseModelFactoryOptions options); | ||
|
||
/// <summary> | ||
/// Connects to the database using the given connection and creates a <see cref="DatabaseModel" /> | ||
/// for the database. | ||
/// </summary> | ||
/// <param name="connection"> The connection to the database to reverse engineer. </param> | ||
/// <param name="options"> The options specifying which metadata to read. </param> | ||
/// <returns> The database model. </returns> | ||
public abstract DatabaseModel Create(DbConnection connection, DatabaseModelFactoryOptions options); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/EFCore.Relational/Scaffolding/DatabaseModelFactoryOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Utilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Scaffolding | ||
{ | ||
/// <summary> | ||
/// Specifies which metadata to read from the database. | ||
/// </summary> | ||
public class DatabaseModelFactoryOptions | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DatabaseModelFactoryOptions" /> class. | ||
/// </summary> | ||
/// <param name="tables"> A list of tables to include. Empty to include all tables. </param> | ||
/// <param name="schemas"> A list of schemas to include. Empty to include all schemas. </param> | ||
public DatabaseModelFactoryOptions([NotNull] IEnumerable<string> tables, [NotNull] IEnumerable<string> schemas) | ||
{ | ||
Check.NotNull(tables, nameof(tables)); | ||
Check.NotNull(schemas, nameof(schemas)); | ||
|
||
Tables = tables; | ||
Schemas = schemas; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the list of tables to include. If empty, include all tables. | ||
/// </summary> | ||
public virtual IEnumerable<string> Tables { get; } | ||
|
||
/// <summary> | ||
/// Gets the list of schemas to include. If empty, include all schemas. | ||
/// </summary> | ||
public virtual IEnumerable<string> Schemas { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters