Base solution for your next web application
Open Closed

Best practice to add existing database to Asp.net zero #9635


User avatar
0
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


Hi,

What is best practice to add existing database to Asp.net zero and be able to use asp.net 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)
  • User Avatar
    0
    zony created
    Support Team

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

  • User Avatar
    0
    bulutyonetim created

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

  • User Avatar
    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: https://aspnetboilerplate.com/Pages/Documents/Entities

  • User Avatar
    0
    bulutyonetim created

    Hi @gterdem

    Thanks for clarification.