Skip to content

Commit

Permalink
🐛 object is not a valid navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
smitpatel committed Nov 12, 2015
1 parent 9b8ea39 commit fe24548
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/EntityFramework.Core/Metadata/Internal/EntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public virtual Key SetPrimaryKey(
{
if (_baseType != null)
{
throw new InvalidOperationException(CoreStrings.DerivedEntityTypeKey(Name));
throw new InvalidOperationException(CoreStrings.DerivedEntityTypeKey(Name, _baseType.Name));
}

if (_primaryKey != null)
Expand Down Expand Up @@ -379,7 +379,7 @@ public virtual Key AddKey([NotNull] IReadOnlyList<Property> properties,

if (_baseType != null)
{
throw new InvalidOperationException(CoreStrings.DerivedEntityTypeKey(Name));
throw new InvalidOperationException(CoreStrings.DerivedEntityTypeKey(Name, _baseType.Name));
}

foreach (var property in properties)
Expand Down
54 changes: 27 additions & 27 deletions src/EntityFramework.Core/Properties/CoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/EntityFramework.Core/Properties/CoreStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
<value>The '{factory}' cannot create a value generator for property '{property}' on entity type '{entityType}'. Only integer properties are supported.</value>
</data>
<data name="DerivedEntityTypeKey" xml:space="preserve">
<value>The derived type '{derivedType}' cannot have keys other than those declared on the root type.</value>
<value>The derived type '{derivedType}' cannot have keys other than those declared on the root type '{rootType}'.</value>
</data>
<data name="CircularInheritance" xml:space="preserve">
<value>The entity type '{entityType}' cannot inherit from '{baseEntityType}' because '{baseEntityType}' is a descendent of '{entityType}'.</value>
Expand Down
3 changes: 2 additions & 1 deletion src/Shared/PropertyInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static Type FindCandidateNavigationPropertyType(this PropertyInfo propert

if (isPrimitiveProperty(targetType)
|| targetType.GetTypeInfo().IsInterface
|| targetType.GetTypeInfo().IsValueType)
|| targetType.GetTypeInfo().IsValueType
|| targetType == typeof(object))
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,10 @@ public void Adding_keys_throws_when_there_is_a_parent_type()
b.HasBaseType(a);

Assert.Equal(
CoreStrings.DerivedEntityTypeKey(typeof(B).FullName),
CoreStrings.DerivedEntityTypeKey(typeof(B).FullName, typeof(A).FullName),
Assert.Throws<InvalidOperationException>(() => b.SetPrimaryKey(b.AddProperty("G"))).Message);
Assert.Equal(
CoreStrings.DerivedEntityTypeKey(typeof(B).FullName),
CoreStrings.DerivedEntityTypeKey(typeof(B).FullName, typeof(A).FullName),
Assert.Throws<InvalidOperationException>(() => b.AddKey(b.AddProperty("E"))).Message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ public void Key_throws_for_derived_type()
var derivedEntityBuilder = modelBuilder.Entity(typeof(SpecialOrder), ConfigurationSource.Convention);
derivedEntityBuilder.HasBaseType(entityBuilder.Metadata, ConfigurationSource.Convention);

Assert.Equal(CoreStrings.DerivedEntityTypeKey(typeof(SpecialOrder).FullName),
Assert.Equal(CoreStrings.DerivedEntityTypeKey(typeof(SpecialOrder).FullName, typeof(Order).FullName),
Assert.Throws<InvalidOperationException>(() =>
derivedEntityBuilder.HasKey(new[] { Order.IdProperty.Name, Order.CustomerIdProperty.Name }, ConfigurationSource.DataAnnotation)).Message);
}
Expand Down Expand Up @@ -764,7 +764,7 @@ public void PrimaryKey_throws_for_derived_type()
var derivedEntityBuilder = modelBuilder.Entity(typeof(SpecialOrder), ConfigurationSource.Convention);
derivedEntityBuilder.HasBaseType(entityBuilder.Metadata, ConfigurationSource.Convention);

Assert.Equal(CoreStrings.DerivedEntityTypeKey(typeof(SpecialOrder).FullName),
Assert.Equal(CoreStrings.DerivedEntityTypeKey(typeof(SpecialOrder).FullName, typeof(Order).FullName),
Assert.Throws<InvalidOperationException>(() =>
derivedEntityBuilder.PrimaryKey(new[] { Order.IdProperty.Name, Order.CustomerIdProperty.Name }, ConfigurationSource.DataAnnotation)).Message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ private class EntityWithNoValidNavigations
{
public int Id { get; set; }

public object Object { get; set; }

public static OneToManyDependent Static { get; set; }

public OneToManyDependent WriteOnly
Expand Down

0 comments on commit fe24548

Please sign in to comment.