public void CreateProxy_throws_for_shared_type_entity_types_when_entity_type_name_not_known() { using var context = new NeweyContext(); Assert.Equal( ProxiesStrings.EntityTypeNotFoundShared(nameof(SharedTypeEntityType)), Assert.Throws <InvalidOperationException>(() => context.CreateProxy <SharedTypeEntityType>()).Message); Assert.Equal( ProxiesStrings.EntityTypeNotFoundShared(nameof(SharedTypeEntityType)), Assert.Throws <InvalidOperationException>(() => context.CreateProxy <SharedTypeEntityType>(_ => { })).Message); Assert.Equal( ProxiesStrings.EntityTypeNotFoundShared(nameof(SharedTypeEntityType)), Assert.Throws <InvalidOperationException>(() => context.CreateProxy(typeof(SharedTypeEntityType))).Message); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual object Create( DbContext context, Type type, params object[] constructorArguments) { var entityType = context.Model.FindRuntimeEntityType(type); if (entityType == null) { if (context.Model.IsShared(type)) { throw new InvalidOperationException(ProxiesStrings.EntityTypeNotFoundShared(type.ShortDisplayName())); } throw new InvalidOperationException(CoreStrings.EntityTypeNotFound(type.ShortDisplayName())); } return(CreateProxy(context, entityType, constructorArguments)); }