プロパティウィンドウに新しいプロパティを追加する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;
}
}
EDIT:https://github.com/devlife/Sandbox
EDIT::私はGitHubの上のコードを置く提案としてマニフェストにMEFコンポーネントを追加した後、まだ拡張決してロードされます。ここでは、マニフェストの写真です:それは結局のところ
あなたはアセンブリがMEFのコンポーネントが含まれていることをマニフェストVSIXに宣言していましたか? – cynic
マニフェストで何も変更しませんでした。私は家に帰るとすぐに見て回ります。 – devlife
それは無事だった。私は質問にマニフェストの絵を追加しました。私はgithub上でコードを試してみましょう。 – devlife