Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc webconfig文件中出现错误_Asp.net Mvc_Asp.net Mvc 4 - Fatal编程技术网

Asp.net mvc webconfig文件中出现错误

Asp.net mvc webconfig文件中出现错误,asp.net-mvc,asp.net-mvc-4,Asp.net Mvc,Asp.net Mvc 4,我是MVC 4的新手。我正在处理一个我在浏览互联网时发现的模型,我正在尝试向我的应用程序添加一个模型。我已经创建了一个模型,当我尝试添加控制器时,它会给我一个错误消息,如 Unable to retrive metadata for 'Practice.Models.Customer'.Invalid value for Key 'attachdbfilename'. 型号: public class Customer { public int ID { get; set; }

我是MVC 4的新手。我正在处理一个我在浏览互联网时发现的模型,我正在尝试向我的应用程序添加一个模型。我已经创建了一个模型,当我尝试添加控制器时,它会给我一个错误消息,如

Unable to retrive metadata for 'Practice.Models.Customer'.Invalid value for Key 'attachdbfilename'. 
型号

public class Customer
 {

    public int ID { get; set; }
    public string Name { get; set; }
    public int Amount { get; set;}
 }
 public class CustomerDBContext : DbContext
 {
    public DbSet<Customer> Customers { get; set; }
 }
   <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-practice-20130320183458;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="CustomerDBContext"
     connectionString="Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\Customers.mdf;Integrated Security=SSPI"
     providerName="System.Data.SqlClient" />
公共类客户
{
公共int ID{get;set;}
公共字符串名称{get;set;}
公共整数金额{get;set;}
}
公共类CustomerDBContext:DbContext
{
公共数据库集客户{get;set;}
}
连接字符串

public class Customer
 {

    public int ID { get; set; }
    public string Name { get; set; }
    public int Amount { get; set;}
 }
 public class CustomerDBContext : DbContext
 {
    public DbSet<Customer> Customers { get; set; }
 }
   <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-practice-20130320183458;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="CustomerDBContext"
     connectionString="Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\Customers.mdf;Integrated Security=SSPI"
     providerName="System.Data.SqlClient" />


我想连接字符串有问题,但不知道它在哪里。请帮我解决这个问题。.提前谢谢。

我想你必须使你的enity虚拟化

public virtual int ID { get; set; }
public virtual string Name { get; set; }
public virtual int Amount { get; set;}