Работа с GUID и платформой объекта

1 ответ

Well if you look at the partial classes the Entity Framework generates by default, there is no default constructor.

So doing this in a separate partial class will work nicely:

public partial class Customer{
    public Customer(){
         _ID = Guid.NewGuid();
    }
}

So there is probably no reason not to do something like you are planning.

You might want to look into T4 templates to do this though. That is how EF 4.0 (i.e. EF in .NET 4.0) allows you to customize the generated code. Now while in 4.0 that experience is quite seemless you could easily put something together based on T4 just to create this partials classes that will work just fine in .NET 3.5 SP1.

Hope this helps

Alex

6
ответ дан 14 December 2019 в 13:43
поделиться
Другие вопросы по тегам:

Похожие вопросы: