我有一個ASP.NET MVC項目,我在近兩個月內還沒有開發過。只要我不更改任何代碼,在瀏覽器中調試就可以正常工作。我修改任何代碼無論如何,即使將空白的那一刻,我得到這個錯誤:System.Web.Routing.RouteCollection和System.Web.Mvc.RouteCollectionExtensions都具有相同的簡單名稱'IgnoreRouteInternal'
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);
唯一的東西我能想到的是,改變路由設置可能是我在再次選擇這個項目之前所做的最後一件事情,據我所知,在那裏一切都很正常。另一件事是我正在使用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}"
);
}
}
}
我不知道如何解決這個
,任何建議將不勝感激。
完美的建議!出於什麼原因,從控制器中產生了一些導致該問題的公共方法。刪除它們解決了問題。謝謝! – Nate