Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Created Issue: .Ignore() and .HasKey() conflict in unexpected ways with Custom Conventions [941]

$
0
0
In example 1, the .HasKey operation is a no operation because the entity contains no entity by the name of "asdf", whereas in the second example a property named "key" does exist, but since it is ignored, we throw an exception.

exception:
The key component 'key' is not a declared property on type 'Entity'. Verify that it has not been explicitly excluded from the model and that it is a valid primitive property.

example 1:
modelBuilder.Entities<Object>()
.Configure(c => c
.Ignore("key"));

modelBuilder.Entities<Entity>()
.Configure(c => c
.HasKey("asdf"));

example 2:
modelBuilder.Entities<Object>()
.Configure(c => c
.Ignore("key"));

modelBuilder.Entities<Entity>()
.Configure(c => c
.HasKey("key"));

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>