0

プロパティウィンドウに新しいプロパティを追加するEFデザイナ用の小さな拡張を作成しました。私はこれをvsixプロジェクト(新しいプロジェクト - > c# - >拡張性 - > vsixプロジェクト)を使って行った。 F5を押すと、実験的なVSインスタンスが起動します。私は新しいプロジェクトを作成し、エンティティデータモデルを追加し、エンティティを追加します。しかし、私のブレークポイントは決して打撃を受けることはなく、私はそのプロパティを見ません。私が間違って何をしているかについてのアイデアは何ですか?Entity Framework Designer Extensionが読み込まれない

public class AggregateRootValue 
{ 
    internal static XName AggregateRootElementName = XName.Get("AggregateRoot", "http://efex"); 

    private readonly XElement _property; 
    private readonly PropertyExtensionContext _context; 

    public AggregateRootValue(XElement parent, PropertyExtensionContext context) 
    { 
     _property = parent; 
     _context = context; 
    } 

    [DisplayName("Aggregate Root")] 
    [Description("Determines if an entity is an Aggregate Root")] 
    [Category("Extensions")] 
    [DefaultValue(true)] 
    public string AggregateRoot 
    { 
     get 
     { 
      XElement child = _property.Element(AggregateRootElementName); 
      return (child == null) ? bool.TrueString : child.Value; 
     } 
     set 
     { 
      using (EntityDesignerChangeScope scope = _context.CreateChangeScope("Set AggregateRoot")) 
      { 
       var element = _property.Element(AggregateRootElementName); 
       if (element == null) 
        _property.Add(new XElement(AggregateRootElementName, value)); 
       else 
        element.SetValue(value); 
       scope.Complete(); 
      } 
     } 
    } 
} 

[Export(typeof(IEntityDesignerExtendedProperty))] 
[EntityDesignerExtendedProperty(EntityDesignerSelection.ConceptualModelEntityType)] 
public class AggregateRootFactory : IEntityDesignerExtendedProperty 
{ 
    public object CreateProperty(XElement element, PropertyExtensionContext context) 
    { 
     var edmXName = XName.Get("Key", "http://schemas.microsoft.com/ado/2008/09/edm"); 
     var keys = element.Parent.Element(edmXName).Elements().Select(e => e.Attribute("Name").Value); 

     if (keys.Contains(element.Attribute("Name").Value)) 
      return new AggregateRootValue(element, context); 

     return null; 
    } 
} 

EDIThttps://github.com/devlife/Sandbox

EDIT::私はGitHubの上のコードを置く提案としてマニフェストにMEFコンポーネントを追加した後、まだ拡張決してロードされます。ここでは、マニフェストの写真です:それは結局のところ

VSIX Manifest

+1

あなたはアセンブリがMEFのコンポーネントが含まれていることをマニフェストVSIXに宣言していましたか? – cynic

+0

マニフェストで何も変更しませんでした。私は家に帰るとすぐに見て回ります。 – devlife

+0

それは無事だった。私は質問にマニフェストの絵を追加しました。私はgithub上でコードを試してみましょう。 – devlife

答えて

2

だから、答えは、どのように私のセットアップ私のプロジェクトです。私は両方のクラスをVSIXファイルを生成するプロジェクトの中に入れました。これらのクラスを別のプロジェクトに移動し、そのプロジェクトをMEFコンポーネントとしてマニフェストに設定するだけで、アセンブリをコピーすることができます。

+0

私は上記を試しましたが、私はまだデザイナーやアイデアに登場するプロパティを見ませんか? – Shimmy

+1

コードはどこにもありますか? – devlife

1

VS2012では、MEFコンポーネントとしてSolutionを追加する必要があります。 MEFコンポーネントとしてもソリューション全体を追加するだけです。 それは驚くほどうまく動作します。

enter image description here

0

私はとにかく、うまくできること(プロジェクトによって構築されたDLLが自動的に生成さVSIXパッケージに含まれていない、とVS2013は、これを変更するには、IDEによってあなたに選択肢を与えるものではありませんようです)。

プロジェクトファイルを手動で開き、XMLを変更する必要があります。変更するプロパティはIncludeAssemblyInVSIXContainerです。

ここで見

How to include VSIX output in it's package?

関連する問題