有人可以解释一下:
- 我正在使用 MVC3/C#/Razor 构建一个项目来习惯使用 MVC。
- 我正在使用内置帐户控制器。
-
我使用实体框架进行连接,将帐户数据存储在本地 SQL 数据库中。
如何轻松生成 EF 接口?
-
到目前为止,我使用的插件来自:http://blog.johanneshoppe.de/2010/10/walkthrough-ado-net-unit-testable-repository-generator/#step1
这允许我为我的实体提供一个接口已经创建了。
但是,我知道我必须更改我的 HomeController
参数以接受真实的存储库或假的存储库进行测试。
我彻底迷路了!
Can somebody please explain:
- I am using MVC3/C#/Razor to build a project to get used to using MVC.
- I am using the inbuilt account controller.
-
I am storing the account data in my local SQL database using Entity Framework to connect.
How can I easily generate interfaces for EF?
-
SO FAR I am using the plugin from: http://blog.johanneshoppe.de/2010/10/walkthrough-ado-net-unit-testable-repository-generator/#step1
This allows me to have an interface for my entities already created.
However, I know that I have to change my HomeController
arguments to accept either the real repository or a fake one for testing.
I am completely lost!
发布评论
评论(1)
看看这些。他们将帮助您入门:
http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application< /a>
http://msdn.microsoft.com/en-us/library/gg416511(VS.98).aspx
对于依赖注入,您可以按照以下步骤操作:
Install-Package Ninject.MVC3
with nuget 到您的 ASP.NET MVC 3 项目(如果您的应用程序使用版本 3)。这基本上会做所有事情。然后在您的控制器上添加以下内容:
转到 App_Start 文件夹内的 NinjectMVC3.cs 文件,并将以下代码添加到
RegisterServices
方法内部:启动您的应用程序,您应该启动了和跑步。
Have a look at these. They will help and get you started :
http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
http://msdn.microsoft.com/en-us/library/gg416511(VS.98).aspx
For dependency injection, you can follow these steps :
Install-Package Ninject.MVC3
with nuget to your ASP.NET MVC 3 project (if your app is on version 3). This will basically do everything.Then have the following on your controller :
Go to NinjectMVC3.cs file inside App_Start folder and add the following code to inside
RegisterServices
method :Fire up your app and you should be up and running.