diff --git a/src/EFCore.Jet/Metadata/Conventions/JetValueGeneratorConvention.cs b/src/EFCore.Jet/Metadata/Conventions/JetValueGeneratorConvention.cs
index a5934c9..68883a2 100644
--- a/src/EFCore.Jet/Metadata/Conventions/JetValueGeneratorConvention.cs
+++ b/src/EFCore.Jet/Metadata/Conventions/JetValueGeneratorConvention.cs
@@ -5,6 +5,7 @@ using EntityFrameworkCore.Jet.Metadata.Internal;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
+using System.Linq;
// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions
@@ -60,25 +61,28 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions
/// The store value generation strategy to set for the given property.
protected override ValueGenerated? GetValueGenerated(IConventionProperty property)
{
- var tableName = property.DeclaringEntityType.GetTableName();
- if (tableName == null)
+ var declaringTable = property.GetMappedStoreObjects(StoreObjectType.Table).FirstOrDefault();
+ if (declaringTable.Name == null)
{
return null;
}
- return GetValueGenerated(property, StoreObjectIdentifier.Table(tableName, property.DeclaringEntityType.GetSchema()));
+ // If the first mapping can be value generated then we'll consider all mappings to be value generated
+ // as this is a client-side configuration and can't be specified per-table.
+ return GetValueGenerated(property, declaringTable);
}
///
/// Returns the store value generation strategy to set for the given property.
///
- /// The property.
- /// The identifier of the store object.
- /// The store value generation strategy to set for the given property.
- public static ValueGenerated? GetValueGenerated([NotNull] IProperty property, in StoreObjectIdentifier storeObject)
+ /// The property.
+ /// The identifier of the store object.
+ /// The store value generation strategy to set for the given property.
+ public new static ValueGenerated? GetValueGenerated(IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
=> RelationalValueGenerationConvention.GetValueGenerated(property, storeObject)
- ?? (property.GetValueGenerationStrategy(storeObject) != JetValueGenerationStrategy.None
- ? ValueGenerated.OnAdd
- : (ValueGenerated?)null);
+ ?? (property.GetValueGenerationStrategy(storeObject) != JetValueGenerationStrategy.None
+ ? ValueGenerated.OnAdd
+ : null);
+
}
}
\ No newline at end of file