-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix build ef core schema DynamicDataContext #48
- Loading branch information
Maxim Voronov
committed
Aug 8, 2020
1 parent
0b8b5a1
commit 7dfd417
Showing
9 changed files
with
49 additions
and
12 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
31 changes: 31 additions & 0 deletions
31
source/OdataToEntity.EfCore.DynamicDataContext/ModelBuilder/DynamicConventionSetBuilder.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,31 @@ | ||
using Microsoft.EntityFrameworkCore.Metadata.Conventions; | ||
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace OdataToEntity.EfCore.DynamicDataContext.ModelBuilder | ||
{ | ||
public sealed class DynamicConventionSetPlugin : IConventionSetPlugin | ||
{ | ||
public ConventionSet ModifyConventions(ConventionSet conventionSet) | ||
{ | ||
KeyDiscoveryConvention keyDiscoveryConvention = conventionSet.EntityTypeAddedConventions.OfType<KeyDiscoveryConvention>().Single(); | ||
foreach (PropertyInfo propertyInfo in typeof(ConventionSet).GetProperties()) | ||
if (propertyInfo.GetValue(conventionSet) is IList list) | ||
list.Remove(keyDiscoveryConvention); | ||
return conventionSet; | ||
} | ||
} | ||
|
||
public sealed class DynamicConventionSetBuilder : RuntimeConventionSetBuilder | ||
{ | ||
public DynamicConventionSetBuilder(IProviderConventionSetBuilder providerConventionSetBuilder, IEnumerable<IConventionSetPlugin> plugins) | ||
: base(providerConventionSetBuilder, new[] { new DynamicConventionSetPlugin() }) | ||
{ | ||
} | ||
} | ||
|
||
} |
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