Open feldrim opened 6 years ago
Wow, that is a lot of tables. I quite like the idea of using hashes to save on writing time.
It was a pain, a severe pain. Yet thanks to EF POCO Generator, we could manage to make the spaghetti code a little less spaghetti, a lot more manageable. First a shared class library of entities then a Nuget package of them, made the whole ecosystem of systems more manageable. We have customized a lot though and the mappings of bad database design where a foreign key is related to many other foreign keys etc literally ruined us. I can't remember all of them but this hash idea was my solution to one of the problems. If I can remember other customizations, I'll open issues about them too. Maybe it might help enhance the application.
Do we have this in the latest version?
Hi @zbalkan No this case is still open and nothing has been implemented with regard to this case. I do not recommend have a single large database context. It works, but is painfully slow. I recommend installing the generator into every service where you need to access the database. Then use filters to filter down the db context to just the tables you need for the service to function. That way the service can spin up a db context in milliseconds, instead of minutes.
I'm keeping this case open to add a hash value for the columns, data types, keys etc. I'll create an enum for the hash type, MD5, SHA256 etc so users can choose their own.
We have used EF POCO Generator for a legacy enterprise application with about 3400+ tables and 800+ views. It was database-first using EDMX files. But we were not going to use all of them, it was a shared database for different services. Name or scheme based filtering wasn't enough.
So we used XML file to list all the tables which we produced from EDMX by replacing unused data using Regex, then manually delete the table names we would not use. We then had an XML object consisting of name and hash properties. Hash values are created with customized T4 template by checking the columns, data types, keys et cetera and making an MD5 hash of them. So next time it will check hash values then try to create the POCO if needed.
It's CPU heavy but it requires less RAM since it creates only the changed entities. Writing files and adding them to project requires more time than all the computing. Overall it was helpful but needs more optimization. So:
would be a good enhancement.