[ConditionalFact] // Issue #22407
        public void CreateProxy_throws_for_weak_entity_types()
        {
            using var context = new NeweyContext();

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy <IsWeak>()).Message);

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy <IsWeak>(_ => { })).Message);

            Assert.Equal(
                ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
                Assert.Throws <InvalidOperationException>(() => context.CreateProxy(typeof(IsWeak))).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()));
                }

                if (context.Model.HasEntityTypeWithDefiningNavigation(type))
                {
                    throw new InvalidOperationException(ProxiesStrings.EntityTypeNotFoundWeak(type.ShortDisplayName()));
                }

                throw new InvalidOperationException(CoreStrings.EntityTypeNotFound(type.ShortDisplayName()));
            }

            return(CreateProxy(context, entityType, constructorArguments));
        }