基于MySQL表创建C#类
.Net 或 Visual Studio 中是否有内置的东西可以让我基于 MySql 表创建类。我想我正在谈论坚持。我只希望该类是表的 1 对 1 映射。有免费的东西存在吗?
Is there anything built into .Net or visual studio that will allow my to create classes based off of a MySql table. I guess I am talking about persistence. I just want the class to be a 1 to 1 mapping of the table. Does anything free exist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
也许你需要这样的东西:
maybe you need something like this:
我调整了MeelStorm的sql,因为它出现了一些关于语言的错误。我还放置了其他类型的数据,并删除了类声明,因为这对我来说是不必要的。所以最终的结果是:
希望有帮助。干杯!
I adjusted the sql of MeelStorm because it was appearing some errors regarding the language. I put other types of data as well and I drop the class declaration because this is unnecessary to me. So the final result is:
Hope it helps. Cheers!
这是伟大的工作:
http://www.code4copy .com/post/generate-c-sharp-model-class-mysql-table
创建一个过程如下:
但是需要一些手动工作。
here is great work done :
http://www.code4copy.com/post/generate-c-sharp-model-class-mysql-table
Create a procedure as follows :
However a little manual work will require.
您可以为此使用实体框架。它与 MySQL 连接良好。
我一直在关注本教程: http://www.devart.com/dotconnect /mysql/articles/tutorial_ef.html
You can use the Entity Framework for this. It connects well with MySQL.
I've been following this tutorial: http://www.devart.com/dotconnect/mysql/articles/tutorial_ef.html
似乎有一种方法可以让 EntityFramework 与 MySQL 一起使用
将 MySQL 与 Entity Framework 结合使用
< a href="http://weblogs.asp.net/gunnarpeipman/archive/2010/12/09/getting-mysql-work-with-entity-framework-4-0.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/gunnarpeipman/archive/2010/12/09/getting-mysql-work-with-entity-framework-4-0.aspx
there appears to be a way to get EntityFramework working with MySQL
Using MySQL with Entity Framework
http://weblogs.asp.net/gunnarpeipman/archive/2010/12/09/getting-mysql-work-with-entity-framework-4-0.aspx
您还可以将 LINQ to SQL 与 MySQL 结合使用。但是,您应该进行一些研究以找到您必须安装的正确提供程序。
我认为这里几乎已经涵盖了:
LINQ to MySQL
You could also use LINQ to SQL with MySQL. But then, you should research a bit to find the correct provider you'd have to install.
I think it pretty much has it covered here:
LINQ to MySQL
我将 NHibernate 与 MyGeneration 结合使用
MyGeneration 是一个程序,可以读取数据库架构并根据模板生成代码(在NHibernate 的情况,实体和映射)
I use NHibernate with MyGeneration
MyGeneration is a program that can read your database schema and generate code based on a template (in the case of NHibernate, the Entities and Mappings)
第一个示例非常好,但缺少一些类型,因此我分享添加缺少的类型(set、float 等..)
The first example is very good but some types are missing so I'm sharing adding missing types (set, float etc ..)
虽然它没有给出期望的结果,但已经很接近了。可以开发。
Although it does not give the desired result, it is close. can be developed.
下面是一个将 mysql 表转换为带有必填字段的 C# 模型类的示例。希望对您有所帮助。
Here is an example to convert mysql table to c# model class with required field. Hope it will be helpful for you.
NHibernate 可以连接到 MySQL 并且是免费的:
https://nhibernate.info/
NHibernate can connect to MySQL and is Free:
https://nhibernate.info/
Subsonic(开源)可与 MySQL (5.0+) 配合使用,并特别支持 InnoDB -
http://subsonicproject.com/
Subsonic (open source) works with MySQL (5.0+) with special support for InnoDB -
http://subsonicproject.com/