Automatically create friend classes from model in C #

I use Linq for Sql (although this is equally applicable in the Entity Framework) for my models, and I always find that I create friend classes for my models. I find it a lot of time and many times. Is there an easy way to automatically generate these friend classes based on models? Perhaps a visual studio macro?

An example of the buddy class that I would like to create:

[MetadataType(typeof(PersonMetadata))]
public partial class Person
{
}

public class PersonMetadata
{
    public object Id { get; set; }

    public object FirstName { get; set; }
}

Thanks in advance.

+3
source share
4 answers

(tt) Visual Studio 2010 ( , 2008 , , 2010 ).

, , LINQ to SQL - .

+1

. - . . . , .

+3

T4.

- .

ORM. SQL , , . , , , , , , , n-, db , DBA. , .

- db Visual Studio. 1200 , String Template library. 6 .

+1

, T4. Oleg Sych. , CodeSmith MyGeneration.

, Entity Framework, Self-Tracking Entities, T4, .EDMX . L2S .

, . !

0

Source: https://habr.com/ru/post/1743240/


All Articles