我目前正在使用SQL Server DB和Code First EF編寫.NET MVC應用程序。一切都很順利,並且stackoverflow非常有幫助。不幸的是,我有一個我無法解決的問題,我無法在互聯網上找到任何幫助。如何使用MVC和實體框架排除模型作爲數據庫的一部分
我想要與貝寶集成,我跟隨http://logcorner.com/asp-net-mvc-paypal-integration這似乎相當直接,除了VS想爲我的貝寶模型創建一個數據庫表,我不需要或不需要它。我在全班同學面前加[NotMapped]
但現在它生成此錯誤:
The type 'MyApp.Models.PayPal' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive or generic, and does not inherit from EntityObject.
我看到關於我的分貝範圍內的OnModelCreating()
方法將忽略(lambda表達式)一些其他的信息,但是,這似乎是排除一列,而不是全班。
任何想法?我不希望我的應用程序中的每個模型都有一個數據庫表。
這個釘了它,謝謝@Rajput。我沒有注意到DbContext類添加了** public System.Data.Entity.DbSet PayPals {get;組; }** 在底部。 –
adeldegan
標記爲答案和upvoted,但顯然我的代表是低到有我的upvote數。真誠的謝謝你的迴應。 – adeldegan
歡迎您光臨@adeldegan – Rajput