EF针对SQL数据库项目的反向POCO? [英] EF Reverse POCO against a SQL Database Project?

查看:129
本文介绍了EF针对SQL数据库项目的反向POCO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以直接对SQL数据库项目使用EF反向POCO生成器吗?

我将SQL数据库定义保存在"Visual Studio SQL数据库项目"中,这为我提供了一些不错的版本控制功能,模式比较以及一些出色的部署功能.有时,我在开发过程中会从临时数据库中更新项目文件,但受版本控制的项目始终是任何版本的真相".

I keep my SQL database definition in a "Visual Studio SQL Database Project", which gives me some nice version control capabilities, schema comparison, and a few nifty deployment features. Sometimes I update the project files from a temporary database during development, but the version-controlled project is always the "truth" for any version.

如果我使用 EntityFramework反向POCO代码优先生成器,我是否需要往返真相"通过实际的SQL数据库生成POCO?还是可以针对VS数据库项目使用POCO生成器?

If I use the EntityFramework Reverse POCO Code First Generator, will I need to round-trip my "truth" through an actual SQL database to generate POCO? Or can I use the POCO generator against a VS Database Project?

我知道数据库项目的模式在各种VS数据库交互中都有某种元存在.例如,它在SQL Server对象资源管理器中以真实的数据库图标显示.但是我不知道代码优先生成器是否可以/确实利用类似的功能来查询元数据.

I know that the schema of a database project has a sort of meta-presence in various VS database interactions. For example, it shows up with a real database icon in the SQL Server Object Explorer. But I don't know if the code-first generator could/does leverage a similar ability to query it for metadata.

推荐答案

有一个名为 SqlSharpener 的项目.在GitHub上以NuGet软件包的形式提供.

There is a project called SqlSharpener on GitHub available as a NuGet package.

说明:

解析SQL文件以创建一个元对象层次结构,您可以使用该层次结构 生成C#代码,例如存储过程包装程序或Entity Framework 代码优先实体.手动生成或通过调用以下方法之一生成 包括预编译的T4模板.

Parses SQL files to create a meta-object hierarchy with which you can generate C# code such as stored procedure wrappers or Entity Framework Code-First entities. Generate either manually or by invoking one of the included pre-compiled T4 templates.

而不是从数据库生成代码或使用繁重的代码 可能会遗漏数据库与数据库之间的差异的抽象层 数据访问层直到运行时,该项目旨在提供一个非常 在设计时生成的快速,简单的数据访问层 使用SQL文件作为事实来源(例如在SSDT中找到的文件) 项目).

Rather than generating code from the database or using a heavy abstraction layer that might miss differences between the database and data access layer until run-time, this project aims to provide a very fast and simple data access layer that is generated at design-time using SQL files as the source-of-truth (such as those found in an SSDT project).

我不能担保它,因为我从未使用过它,但是看起来很有希望.

I cannot vouch for it because I have never used it but it seems promising.

这篇关于EF针对SQL数据库项目的反向POCO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆