diff --git a/src/EFCore.Jet/Extensions/JetReferenceCollectionBuilderExtensions.cs b/src/EFCore.Jet/Extensions/JetReferenceCollectionBuilderExtensions.cs new file mode 100644 index 0000000..b83f94e --- /dev/null +++ b/src/EFCore.Jet/Extensions/JetReferenceCollectionBuilderExtensions.cs @@ -0,0 +1,27 @@ +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Runtime.CompilerServices; +using EntityFrameworkCore.Jet.Metadata; +using EntityFrameworkCore.Jet.Metadata.Internal; +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore.Metadata; +using EntityFrameworkCore.Jet.Utilities; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +// ReSharper disable once CheckNamespace +namespace Microsoft.EntityFrameworkCore +{ + /// + /// Jet specific extension methods for . + /// + public static class JetReferenceCollectionExtensions + { + public static ReferenceCollectionBuilder MatchSimple(this ReferenceCollectionBuilder referenceCollectionBuilder) + where TPrincipalEntity : class + where TDependentEntity : class + { + referenceCollectionBuilder.Metadata.SetAnnotation(JetAnnotationNames.Prefix + "MatchSimple", "MatchSimple"); + return referenceCollectionBuilder; + } + } +} \ No newline at end of file diff --git a/src/EFCore.Jet/Metadata/Internal/JetAnnotationProvider.cs b/src/EFCore.Jet/Metadata/Internal/JetAnnotationProvider.cs index aa6f46a..0cf4d5a 100644 --- a/src/EFCore.Jet/Metadata/Internal/JetAnnotationProvider.cs +++ b/src/EFCore.Jet/Metadata/Internal/JetAnnotationProvider.cs @@ -6,6 +6,7 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.Extensions.DependencyInjection; namespace EntityFrameworkCore.Jet.Metadata.Internal @@ -120,6 +121,19 @@ namespace EntityFrameworkCore.Jet.Metadata.Internal } } + public override IEnumerable For(IForeignKeyConstraint foreignKey, bool designTime) + { + var table = StoreObjectIdentifier.Table(foreignKey.Table.Name, foreignKey.Table.Schema); + foreach (var fk in foreignKey.MappedForeignKeys) + { + if (fk.FindAnnotation(JetAnnotationNames.Prefix + "MatchSimple") != null) + { + yield return new Annotation(JetAnnotationNames.Prefix + "MatchSimple", "MatchSimple"); + } + } + } + + private static bool HasConverter(IProperty property) => (property.GetValueConverter() ?? property.FindTypeMapping()?.Converter) != null; }