asp.net无法检索元数据 [英] asp.net unable to retrieve metadata

查看:144
本文介绍了asp.net无法检索元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个问题,MVC的控制器,即使在阅读提示后。
在DbContext上添加一个构造函数,删除无效的,改变providerName =System.Data.SqlClient等等。

hi i am having a issue with MVC to make a controller even after reading the tips. adding a constructor on the DbContext, deleting the non worked, changing providerName="System.Data.SqlClient" and so on.

我的模型类看起来像这个:

my model class look like this:

public class RecruiterModel
{
    public string CompanyName { get; set; }
    public string Website { get; set; }
    public string CompanySize { get; set; }
    public string LinkedInCompanyURL { get; set; }
    public string LinkedInID { get; set; }
    public string Specialities { get; set; }
    public string Category { get; set; }
    public string Location { get; set; }
    public int ContactPhone { get; set; }
    public string ContactEmail { get; set; }
}

public class RecruiterDBContext : DbContext
{

    public DbSet<RecruiterModel> Recruiters { get; set; }
}

并且我的web.config connectionStrings如下所示:

and my web.config connectionStrings looks like this:

<add name="ApplicationServices"
     connectionString="data source=.\SQLEXPRESS;Integrated  Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
     providerName="System.Data.SqlClient" />
<add name="RecruiterDBContext"
     connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Recruiters.mdf;Integrated Security=True"
     providerName="System.Data.SqlClient"
/>

任何提示?

推荐答案

我找到了创建控制器类的解决方案:
在模型类上,我添加了

I have found the solution to create the controller class: On the model class i added the

使用System.ComponentModel.DataAnnotations ;

using System.ComponentModel.DataAnnotations;

public class RecruiterModel
{
[Key]
public string Id {get;组;

public class RecruiterModel { [Key] public string Id { get; set;

然后在web.config上注释掉整个

then on the web.config i commented out the whole

connectionStrings标记

connectionStrings tag

然后我创建了控制器,但它工作。

then i created the controller but and it worked.

感谢gos出Alex Filipovici和杨杨 - MSFT上:
http://forums.asp.net/t/1888573.aspx/1?Unable+to+retrieve+metadata+for+when+trying+to+create+a+controller

thanks gos out to Alex Filipovici and Young Yang - MSFT on: http://forums.asp.net/t/1888573.aspx/1?Unable+to+retrieve+metadata+for+when+trying+to+create+a+controller

虽然它的工作,但在解决方案资源管理器选项卡下的App_Data我看不到数据库文件... hmm另一个问题。

though it works but on the Solution Explorer tab under App_Data i do not see the db file... hmm another issue.

这篇关于asp.net无法检索元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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