2017-12-08 10 views
0

私のプロジェクトにはKeyクラスがあります。ここでDBにエントリを追加できません(ASP.NET MVC)

はコード

public partial class Key 
{ 
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] 
    public Key() 
    { 
     this.Appointments = new HashSet<Appointment>(); 
    } 

    public int Id { get; set; } 
    public string Key1 { get; set; } 
    public string English { get; set; } 
    public string German { get; set; } 

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] 
    public virtual ICollection<Appointment> Appointments { get; set; } 
} 

であると私は、エントリを追加するために必要なもの、クラスはこのテーブルに関連しているのキーテーブルを持っています。ここで

public ActionResult AddNewKey(string german, string english, string keyVal, 
     string typeOfInvestigation) 
    { 
     using (var ctx = new ApplicationDbContext()) 
     { 
      Key key = new Key() 
      { 
       German = german, 
       English = english, 
       Key1 = keyVal, 
       //Type_of_investigation_principle = typeOfInvestigation 

      }; 
      ctx.Keys.Add(key); 
      ctx.SaveChanges(); 
      return Json(new {Result = "Success", Message = "Saved Successfully"}); 
     } 
    } 

を追加するためのバックエンドのコードである。しかしAdd(key)に、私はエラーを持っています。

シンボルはなぜ

を追加解決できませんか?

クリーンで再構築が役に立たない

この問題をどのように解決できますか。 Visual Studioの→メニュー→ツールオプションReSharperの(再び閉鎖する必要がボタンと再開を中断しないように

ゴー:

+0

したがって、どのタイプが 'ApplicationDbContext.Keys'ですか? – CodeCaster

+0

エラーは、Resharper @ CodeCaster –

答えて

0

私は私の場合、私はこれをしませんでした窓)。

これは、ソリューションに同じライブラリの2つの異なるバージョンがある場合に、ReSharperで発生します。たとえば、プロジェクトAはAutoMapperバージョン1.1を参照し、プロジェクトBはAutoMapperバージョン1.0を参照します。

Visual Studioは、バインドするDLLの1つを選択するため、状況に応じてコンパイルして実行することがよくあります。しかし、ReSharperは大規模に混乱します。

+0

Hmにありました。助けになる。しかし、なぜresharperこれを行う? –

+0

更新された回答@OldBalance –

+0

を確認してください。ありがとうございました –

関連する問題