Base solution for your next web application
Open Closed

Best practice to add existing database to zero #9635

bulutyonetim created

What is your product version? 9.0.1 What is your product type (Angular or MVC)? Angular (single solution) What is product framework type (.net framework or .net core)? ASP.NET CORE


What is best practice to add existing database to zero and be able to use zero's features. In fact I don't have problem with importing DB to code first. I am asking because I want to be able use Zero's features after import. Feature's like Full Audit, SoftDelete, MultiTenancy and etc...

Thank you.

4 Answer(s)
  • 0
    zony created
    Support Team

    Hi bulutyonetim, The recommended approach is to write the corresponding Code-First code based on the existing database model.

  • 0
    bulutyonetim created

    Hi I didn't get what you mean, can you explain with an example.

  • 0
    gterdem created
    Support Team

    Hello @bulutyonetim

    You can scaffold your database to code first and having your domain model as code. Afterwards you need to update your entities manually.

    Lets say you have a Person table and after scaffolding you have a Person entity as follows:

    public class Person {
    public Guid Id {get; set;} public string Name { get; set; } public DateTime CreationTime { get; set; } }

    You need to manually update this entity to benefit features like:

    public class Person : Entity<Guid> { public virtual string Name { get; set; } public virtual DateTime CreationTime { get; set; } }

    For more info, you can check here:

  • 0
    bulutyonetim created

    Hi @gterdem

    Thanks for clarification.