简体   繁体   English

在VS2010中设计数据模型并生成ORM代码,应用程序

[英]Designing a data model in VS2010 and generating ORM code, application

Simply put: I have a database design in my head and I now want to use Visual Studio 2010 to create a WPF application. 简而言之:我脑子里有一个数据库设计,现在我想使用Visual Studio 2010创建WPF应用程序。 Key is to use the VS2010 tools to take much as possible manual work out of my hands. 关键是要使用VS2010工具来尽可能多地进行手动操作。

  • The database engine is SQLite 数据库引擎是SQLite
  • ORM probably through DBLINQ ORM 可能通过DBLINQ
  • Use of LINQ LINQ的使用
  • The application can create new, empty database instances 应用程序可以创建新的空数据库实例
  • Easily maintainable (changes in data model possible) 易于维护(可能更改数据模型)

Questions 问题

  • How do I start designing the database model (visually) in Visual Studio 2010? 如何开始在Visual Studio 2010中(可视化)设计数据库模型? Should this be an xsd? 应该是xsd吗? Do I do this in a separate project? 我要在一个单独的项目中执行此操作吗?
  • Next, how can I make the most use of VS2010 code generation tools to generate a Data Access Layer? 接下来,如何充分利用VS2010代码生成工具来生成数据访问层?
  • I suppose the Data Access Layer will be added as a Data Source (in another project?) and from there it's a rather generic data binding solution? 我想数据访问层将作为数据源添加(在另一个项目中?),从那里有一个相当通用的数据绑定解决方案?

I tried finding clear examples of this but it's a jungle out there, the hunt for a solution is NOT converging to one clear method. 我试图找到明确的例子,但这只是一个丛林,寻求解决方案并没有收敛到一个明确的方法。

Update 更新资料

So I decided to use ADO.NET entity framework, DBLINQ is out of the picture. 因此我决定使用ADO.NET实体框架,而DBLINQ是无法实现的。 I downloaded and installed the System.Data.SQLite ADO.NET provider which integrates with VS2010. 我下载并安装了与VS2010集成的System.Data.SQLite ADO.NET提供程序。 From the VS2010 Server Explorer one can create and design a new database but it could be done with a standalone tool for SQLite as well. 通过VS2010 Server Explorer,可以创建和设计新数据库,但是也可以使用SQLite的独立工具来完成。 I then created a new WPF application project, and in the solution explorer added an ADO.NET Entity Data Model, which automatically generates an edmx with C# code (which is the Data Access Layer) from the already created database file. 然后,我创建了一个新的WPF应用程序项目,并在解决方案资源管理器中添加了ADO.NET实体数据模型,该模型自动从已创建的数据库文件中生成带有C#代码的edmx(即数据访问层)。 WAF (waf.codeplex.com) seems like a good idea to implement the rest but plain LINQ to SQL will do. WAF(waf.codeplex.com)似乎是实现其余部分的一个好主意,但是普通的LINQ to SQL可以实现。 This (click here) is also a very helpful question on stackoverflow. 这(单击此处)对于stackoverflow也是一个非常有用的问题。

Kay, 凯,

Please consider using ADO .NET Framework. 请考虑使用ADO .NET Framework。 It's supported by VS 2010 and LINQ ( quick article ). VS 2010和LINQ都支持它( 快速文章 )。

There is one thing you must know before designing your architecture. 设计架构之前,您必须了解一件事。 BLL (Business Logic Layer) is a layer of logic specific for a particular data usage, hence cannot be generated automatically by (whatever you will use) framework. BLL(业务逻辑层)是特定于特定数据使用的逻辑层,因此无法(无论使用什么)框架自动生成。 I guess you had Data Access Layer in mind - don't worry about that - if you're going to use ADO .NET and LINQ to Entities, DAL will be generated for you automatically. 我猜想您已经想到了数据访问层-不用担心-如果您要使用ADO .NET和LINQ to Entities,DAL将自动为您生成。 LINQ to Entities together with ADO .NET Framework are powerful set of tools which should 100% cover your needs. LINQ to Entities和ADO .NET Framework是功能强大的工具集,应100%满足您的需求。 Additional info about LINQ to Entities . 有关LINQ to Entities的附加信息

Please feel free to ask if you have any questions. 请随时询问您是否有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM