Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Scaffold common base class for all entities

$
0
0
Creating ASP.NET 5 Core MVC application using Npgsql EF Core provider.

Scaffold creates Poco classes like

    namespace MyDbContext
    {
        public partial class Customer
        {
            public Customer()
            {
            }
    
            public string Id { get; set; }
            public string Name { get; set; }
       }
    }


How to force it to generate common base class for all entities like

        public partial class Customer : EntityBase
        { }

or generic base class

      public partial class Customer : EntityBase<Customer>
        { }

Scaffold is perfomed at runtime. So it it not possible to manually change created code or add partial classes for every table.
Docs in https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding does not describe such option in

    dotnet ef dbcontex

command.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>