Unique keys in Entity Framework 4

前端 未结 5 691
猫巷女王i
猫巷女王i 2020-11-28 12:13

An existing DB schema has unique, non-primary, keys, and some foreign keys that rely on them.

Is it possible to define unique keys, which are not primary keys, in

5条回答
  •  眼角桃花
    2020-11-28 12:41

    I've tried defining the following tables:

    • Orders [Id (primary, identity), ClientName, FriendlyOrderNum (unique)]
    • OrderItems [Id (primary, identity), FriendlyOrderNum (unique), ItemName]

    And a foreign key mapping from OrderItems.FriendlyOrderNum (Mant) to Orders.FriendlyOrderNum (one).

    If unique non-primary keys are possible the following SSDL should work:

    
        
          
          
        
        
          
            
          
          
          
          
        
        
        
          
            
          
          
          
          
        
    
      
        
          
          
          
          
            
              
            
            
              
            
          
        
      
    

    It doesn't. There's also no possibility for adding more elements in an .

    My conclusion is that non-primary unique keys are not support in EF 4.

提交回复
热议问题