Here are some options:
A. Use the USER_CODE_REGION. Whatever you put in there is kept as-is after code re-generations. I think this is the easy one.
public override IEntity2 Create(IEntityFields2 fields) {
IEntity2 toReturn = new AspnetUsersEntity(fields);
// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerUsingFields
toReturn = DIContainer.Get<AspnetUsersEntity>(fields);
// __LLBLGENPRO_USER_CODE_REGION_END
return toReturn;
}
B. Create an inherited version of the factory. Override the Create method:
public partial class MyCustomAspnetUserEntityFactory : AspnetUserEntityFactory
{
public MyCustomAspnetUserEntityFactory ()
: base()
{ }
public override IEntity2 Create(IEntityFields2 fields)
{
IEntity2 toReturn = DIContainer.Get<AspnetUsersEntity>(fields);
return toReturn;
}
}
Then you can use it to create the involved entity...:
var factory = new MyCustomAspnetUserEntityFactory ();
var aspnetUser = factory.Create();
... or you can create a custom AspnetUserEntity that inherit from the original and use the custom factory:
public class MyCustomAspNetEntity : AspnetUserEntity
{
protected override IEntityFactory2 CreateEntityFactory()
{
return EntityFactoryCache2.GetEntityFactory(typeof(MyCustomAspnetUserEntityFactory ));
}
}