Scaffolding with buddy class

Oct 31, 2011 at 7:22 AM

Hey ho!

I can't get the scaffolder work with a buddy class!
Simple example:

FILE(1): Models\IPAddress.cs

namespace BuddyClassTest.Models{ 
	public partial class IPAddress { 
		public int IDIP {get; set;} 
		public int? IDNS {get; set;} 
		public virtual Nameserver Nameserver {get; set;} 
	} 
}
 

FILE(2): Models\IPAddressMetadata.cs

 

namespace BuddyClassTest.Models{ 	 
	[MetadataType(typeof(IPAddressMetadata))] 
	partial class IPAddress { }
	partial class IPAddressMetadata { 		
		[Key]		
		public int IDIP {get; set;} 
		[ForeignKey("Nameserver")]		
		public int? IDNS {get; set;} 		
		public virtual Nameserver Nameserver {get; set;} 
	} 
}
 
If I now try to scaffold with:
SCAFFOLD Controller IPAddress -dbcontext BuddyClassTestEntities -Repository -force
 
I get the error:
Get-PrimaryKey: Cannot find primary key property for type "BuddyClassTest.Models.IPAddress". No Properties appear to be primary.
 
 
If add the "[Key]" Attribute to the first file, all works fine. 
I use the DBFirst approach with the "MvcScaffolding.EntityMetadata" package and the first file will be overwritten by another scaffolder, so I want the Metadata (or Attributes) in a diffrent file.
Any help or is this not possilbe or is this an issue ?
Thanks!
UBruns