forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add public API to build provider-specific convention sets without usi…
…ng DI Fixes dotnet#3529
- Loading branch information
1 parent
5ae361b
commit 3445477
Showing
33 changed files
with
141 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
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
16 changes: 0 additions & 16 deletions
16
src/EntityFramework.Sqlite/Metadata/Conventions/Internal/SqliteConventionSetBuilder.cs
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
src/EntityFramework.Sqlite/Metadata/Conventions/SqliteConventionSetBuilder.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,22 @@ | ||
// 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 JetBrains.Annotations; | ||
using Microsoft.Data.Entity.Metadata.Conventions.Internal; | ||
using Microsoft.Data.Entity.Storage; | ||
using Microsoft.Data.Entity.Storage.Internal; | ||
|
||
namespace Microsoft.Data.Entity.Metadata.Conventions | ||
{ | ||
public class SqliteConventionSetBuilder : RelationalConventionSetBuilder | ||
{ | ||
public SqliteConventionSetBuilder([NotNull] IRelationalTypeMapper typeMapper) | ||
: base(typeMapper) | ||
{ | ||
} | ||
|
||
public static ConventionSet Build() | ||
=> new SqliteConventionSetBuilder(new SqliteTypeMapper()) | ||
.AddConventions(new CoreConventionSetBuilder().CreateConventionSet()); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
test/EntityFramework.Core.Tests/Metadata/Conventions/ConventionSetBuilderTests.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,33 @@ | ||
// 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.ComponentModel.DataAnnotations.Schema; | ||
using System.Linq; | ||
using Microsoft.Data.Entity.Metadata.Conventions.Internal; | ||
using Xunit; | ||
|
||
namespace Microsoft.Data.Entity.Metadata.Conventions.Tests | ||
{ | ||
public class ConventionSetBuilderTests | ||
{ | ||
[Fact] | ||
public virtual IModel Can_build_a_model_with_default_conventions_without_DI() | ||
{ | ||
var modelBuilder = new ModelBuilder(GetConventionSet()); | ||
modelBuilder.Entity<Product>(); | ||
|
||
var model = modelBuilder.Model; | ||
Assert.Equal(2, model.GetEntityTypes().Single().GetProperties().Count()); | ||
return model; | ||
} | ||
|
||
protected virtual ConventionSet GetConventionSet() => new CoreConventionSetBuilder().CreateConventionSet(); | ||
|
||
[Table("ProductTable")] | ||
protected class Product | ||
{ | ||
public virtual int Id { get; set; } | ||
public virtual string Name { get; set; } | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
25 changes: 25 additions & 0 deletions
25
...ework.MicrosoftSqlServer.Tests/Metadata/Conventions/SqlServerConventionSetBuilderTests.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,25 @@ | ||
// 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.Linq; | ||
using Microsoft.Data.Entity.Metadata; | ||
using Microsoft.Data.Entity.Metadata.Conventions; | ||
using Microsoft.Data.Entity.Metadata.Conventions.Tests; | ||
using Xunit; | ||
|
||
namespace Microsoft.Data.Entity.SqlServer.Metadata.Conventions.Tests | ||
{ | ||
public class SqlServerConventionSetBuilderTests : ConventionSetBuilderTests | ||
{ | ||
public override IModel Can_build_a_model_with_default_conventions_without_DI() | ||
{ | ||
var model = base.Can_build_a_model_with_default_conventions_without_DI(); | ||
|
||
Assert.Equal("ProductTable", model.GetEntityTypes().Single().SqlServer().TableName); | ||
|
||
return model; | ||
} | ||
|
||
protected override ConventionSet GetConventionSet() => SqlServerConventionSetBuilder.Build(); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
test/EntityFramework.Sqlite.Tests/Metadata/Conventions/SqliteConventionSetBuilderTests.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,22 @@ | ||
// 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.Linq; | ||
using Xunit; | ||
|
||
namespace Microsoft.Data.Entity.Metadata.Conventions.Tests | ||
{ | ||
public class SqliteConventionSetBuilderTests : ConventionSetBuilderTests | ||
{ | ||
public override IModel Can_build_a_model_with_default_conventions_without_DI() | ||
{ | ||
var model = base.Can_build_a_model_with_default_conventions_without_DI(); | ||
|
||
Assert.Equal("ProductTable", model.GetEntityTypes().Single().Sqlite().TableName); | ||
|
||
return model; | ||
} | ||
|
||
protected override ConventionSet GetConventionSet() => SqliteConventionSetBuilder.Build(); | ||
} | ||
} |