NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

There's opinionated frameworks, and then there's opinionated frameworks that also respect your opinion. LLBLGen is one of those. For many years it's been a great entity modeling tool as well as an excellent ORM (Object Relational Mapper.) It also supports all major ORMs in the .NET space like Entity Framework, NHibernate, Linq to Sql as well as, of course, their own included LLBLGen Pro Runtime Framework. It works with VS2015 and VS2017 and is actively supported and extremely actively developed. It's because of that active development that I wanted to check it out. It's got Getting Started videos and a TON of docs, so I figured I could do some damage pretty quickly with a 30 day trial.

有一个自以为是的框架,然后有一个自以为是的框架也尊重您的意见。 LLBLGen是其中之一。 多年来,它一直是出色的实体建模工具以及出色的ORM(对象关系映射器)。它还支持.NET空间中的所有主要ORM,例如Entity FrameworkNHibernateLinq to Sql以及它们当然自己包括LLBLGen Pro运行时框架。 它与VS2015和VS2017一起使用,并得到了积极的支持和非常积极的开发。 因为要进行积极的开发,所以我想检查一下。 它有入门视频大量文档,所以我认为通过30天的试用可以很快造成一些损害。

NOTE: Just a reminder, I don't do sponsored posts for software. I just felt like checking out LLBLGen because it's been a few years since I looked at it least. All my observations are my own, unfiltered, as I know you like them, Dear Reader.

注意:提醒一下,我不赞助软件帖子。 我只是想查看LLBLGen,因为距离我至少看了已经有几年了。 亲爱的读者,据我所知,我所有的观察都是我自己的,未经过滤。

You can do Database First - a technique that is crucial for so many of us with existing databases but often downplayed with other ORMs - as well as Model First and then generate classes.

您可以执行Database First(数据库优先)和Model First,然后再生成类。这项技术对我们中许多人来说至关重要,而现有数据库却经常被其他ORM淡化。

I decided to start with one of the newer SQL Server 2016 sample databases called Worldwide Importers. There's localdb versions, Azure SQL Database versions, and SQL Server 2016 backups. I made a database in Azure, uploaded a "bacpac" file to Azure storage, and imported the database into SQL Azure. Although I certainly could have done the work locally, I can get more horsepower in the cloud.

我决定从一个名为Worldwide Importers的较新的SQL Server 2016示例数据库开始。 有localdb版本,Azure SQL数据库版本和SQL Server 2016备份。 我在Azure中创建了一个数据库,将“ bacpac”文件上传到Azure存储,然后将该数据库导入了SQL Azure。 尽管我当然可以在本地完成工作,但是我可以在云中获得更多的功能。

When I make a new Project in the LLBLGen GUI I can pick from a ton of different ORMs including 5 (!) versions of Entity Framework including EFCore, as well as NHibernate 4v and Linq to SQL (which is a nice touch as I have two L2S projects still in production.)

当我在LLBLGen GUI中创建一个新项目时,我可以从大量不同的ORM中进行选择,包括5(!)版的Entity Framework,包括EFCore以及NHibernate 4v和Linq to SQL(这很不错,因为我有两个L2S项目仍在生产中。)

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

The WorldWide Importers sample is a nice one as it's typical and non-trivial in complexity. I pointed LLBLGen at it and let it rip. Make sure you wait until your database is totally restored into SQL Azure or your SQL Server or you may get weird errors about Zombie Transactions.

WorldWide Importers示例很不错,因为它的典型性和复杂性很重要。 我将LLBLGen指向它并使其撕裂。 确保等待数据库完全还原到SQL Azure或SQL Server中,否则您可能会收到有关Zombie Transactions的奇怪错误。

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

When it's done, you'll get an Errors & Warnings pane that will tell you how many stored procs, tables, views, etc that were imported, and that they are "unmapped," which is cool since you haven't mapped them.

完成后,您将获得一个错误和警告窗格,该窗格将告诉您导入了多少存储的proc,表,视图等,并且它们是“未映射的”,这很酷,因为您尚未映射它们。

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

You can switch your Target ORM Framework after you've imported your Data Model, but you really should put a little thought into how your database is structured and whether or not your preferred ORM supports all the features you (may) have used heavily in your Database. For example, if you're a very "stored proc"-style shop, it would be a problem if you really wanted to use an ORM that didn't support stored procs.

导入数据模型后,您可以切换目标ORM框架,但您确实应该对数据库的结构以及您首选的ORM是否支持您(可能)已经在您的数据库中大量使用的所有功能进行一些思考。数据库。 例如,如果您是一家非常“存储的proc”样式的商店,那么,如果您确实想使用不支持存储的proc的ORM,将是一个问题。

LLBLGen is rather extraordinary in that it not only has smarts about what's possible and what's not, but it also offers you a multiple-choice solution framework when something is wrong. For example, there's a mapping here that isn't support, so it's offering me three options to fix it, including (of course) changing the offending entity by changing/adding fields.

LLBLGen非常出色,因为它不仅对可能的事和不可能的事都有精明的知识,而且在出现问题时还为您提供了多项选择解决方案框架。 例如,这里有一个不支持的映射,因此它为我提供了三种修复方法,包括(当然)通过更改/添加字段来更改有问题的实体。

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

Once you have a valid model and have corrected any issues and/or made appropriate changes, you can Generate Source Code for your target platform, language, and ORM Framework.

一旦有了有效的模型并纠正了所有问题和/或进行了适当的更改,就可以为目标平台,语言和ORM框架生成源代码。

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

Make no mistake about it - there's a LOT of depth here. There's multiple kinds of templates and tons of options. You may not get it all right on the first try, but it's very forgiving. Just remember where the authoritative source of truth is. Is your model the truth? Or your database? As you move forward (depending on where you started) your source of truth will likely change. You can use any of the many code generators or expand them with your own modifications and metadata.

毫无疑问-这里有很多深度。 有多种模板和大量选项。 初次尝试可能无法完全解决问题,但这是非常宽容的。 只要记住真实的权威来源在哪里。 你的模特是真的吗? 还是你的数据库? 随着您前进(取决于您的起点),真理的来源可能会改变。 您可以使用许多代码生成器中的任何一个,也可以使用自己的修改和元数据来扩展它们。

You'll also likely get addicted to the nice visual editors for entities (a good thing!).

您也可能会迷上实体的漂亮可视编辑器(一件好事!)。

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

Quick Model is also nice if you want to visualize (and change) relationships between just a few of your many tables.

如果您只想可视化(和更改)许多表之间的关系,则“快速模型”也很不错。

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

If you get fast enough, with practice you can use the Quick Model editor and it's Command Input palette to model most of a new database when interviewing domain experts. The visual designer is fast and flexible.

如果您足够快,可以在与领域专家进行访谈时,通过实践使用“快速模型”编辑器及其“命令输入”面板来对大多数新数据库进行建模。 视觉设计师快速灵活

I've truly barely scratched the surface of this deep tool. The pricing is very reasonable considering all it does.

我真的几乎没有触及过这个深层工具的表面。 考虑到它所做的一切,价格非常合理。

Have you used LLBLGen or similar tools lately? What's been your impression?

您最近是否使用过LLBLGen或类似工具? 您的印象如何?



Sponsor: Big thanks to Raygun! Don't rely on your users to report the problems they experience. Automatically detect, diagnose and understand the root cause of errors, crashes and performance issues in your web and mobile apps. Learn more.

赞助商:非常感谢Raygun ! 不要依靠用户来报告他们遇到的问题。 自动检测,诊断和了解Web和移动应用程序中错误,崩溃和性能问题的根本原因。 了解更多

关于斯科特 (About Scott)

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

斯科特·汉塞尔曼(Scott Hanselman)是前教授,前金融首席架构师,现在是演讲者,顾问,父亲,糖尿病患者和Microsoft员工。 他是一位失败的单口相声漫画家,一个玉米种植者和一本书的作者。

NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模
NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模
NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模
About   关于 Newsletter 时事通讯
Hosting By 主持人
NET和.NET Core的LLBLGen Pro-具有任何ORM的数据库实体建模

翻译自: https://www.hanselman.com/blog/llblgen-pro-for-net-and-net-core-database-entity-modeling-with-any-orm