1

私は、ほぼ 2 か月間取り組んでいない ASP.NET MVC プロジェクトを持っています。コードを変更しない限り、ブラウザでのデバッグは正常に機能します。コードを変更した瞬間、空白を追加しても、次のエラーが発生します。

An exception of type 'System.NotSupportedException' occurred in EntityFramework.dll but was not handled in user code

Additional information: The type 'System.Web.Routing.RouteCollection+IgnoreRouteInternal' and the type 'System.Web.Mvc.RouteCollectionExtensions+IgnoreRouteInternal' both have the same simple name of 'IgnoreRouteInternal' and so cannot be used in the same model. All types in a given model must have unique simple names. Use 'NotMappedAttribute' or call Ignore in the Code First fluent API to explicitly exclude a property or type from the model.

例外は次の行で発生します。

var item = Cards.FirstOrDefault(s => s.name == cardName);

私が考えることができる唯一のことは、すべてが正常であると言うことができる限り、ルーティング設定の変更は、おそらくこのプロジェクトを再び取り上げる前に行った最後のことの1つであったということです. もう 1 つは、私は TortiseGit と bitbucket を使用していますが、それがどのような影響を与えるかわかりません。問題のない同様の設定の別のプロジェクトがあります。

間違えた場合のために、これは私の RouteConfig.cs です。

using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace houseOfCards
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Hello",
                url: "{controller}/{action}/{name}/{id}"
                );
        }
    }
}

これを解決する方法がわかりません。何か提案をいただければ幸いです。

4

1 に答える 1

1

私は同様の問題に直面していました.3日間の調査とデバッグの後、私はそれを修正することができました.エラーメッセージは少し誤解を招く傾向がありSystem.Web.Routing.RouteCollectionますSystem.Web.Mvc.RouteCollectionExtensions.それを行いますが、少なくとも私の場合はそうしません。

私の場合、エンティティのナビゲーション プロパティを誤って として宣言したICollection<Controller>ため、登録したいクラスについて Entity Framework が混乱していました。

したがって、予約語またはモデルに属さないクラスとして名前が付けられたプロパティまたはクラスをモデルで検索し、名前を変更することをお勧めします。

役立つことを願っています

于 2015-05-31T23:29:51.747 に答える