Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Adding an attribute to a property in a partial class

Adding an attribute to a property in a partial class

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bernard Laplace
    wrote on last edited by
    #1

    Hi, I am using Entity framework in a dynamic data web app with C#. So far I have created a source file with partial declarations of my entity classes on which I have set attributes like ScaffoldTable. I did that in order to not lose this code in case of regeneration of the entity classes.

     using System.ComponentModel;
     using System.ComponentModel.DataAnnotations;
    
    
     namespace AdmissionForm
     {
    
         \[ScaffoldTable(true)\]
         public partial class AdmissionForm
         {
        
         }
      ...
     }
    

    I would like to know if there is a way to add attributes to the properties defined in this entity classes from the source file I have added. Regards.

    T 1 Reply Last reply
    0
    • B Bernard Laplace

      Hi, I am using Entity framework in a dynamic data web app with C#. So far I have created a source file with partial declarations of my entity classes on which I have set attributes like ScaffoldTable. I did that in order to not lose this code in case of regeneration of the entity classes.

       using System.ComponentModel;
       using System.ComponentModel.DataAnnotations;
      
      
       namespace AdmissionForm
       {
      
           \[ScaffoldTable(true)\]
           public partial class AdmissionForm
           {
          
           }
        ...
       }
      

      I would like to know if there is a way to add attributes to the properties defined in this entity classes from the source file I have added. Regards.

      T Offline
      T Offline
      Thiago Berti
      wrote on last edited by
      #2

      I ran into the same problem here while using .net mvc with LinqToSql classes.. Maybe this can help you.. http://dotnetslackers.com/sql/re-309931_adding_attributes_to_generated_classes.aspx[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups