【发布时间】:2014-12-18 14:17:22
【问题描述】:
我正在使用实体框架 6.1.1
我在一个项目中有一个类,其中包括 FBuyShopContext,另一个用于模型,以及一个带有 MVC 5 的 Asp 项目
在我的第一个项目中,我关注了
public class FBuyShopContext : DbContext
{
public FBuyShopContext()
: base("name=FBuyShopContext")
{
}
public virtual DbSet<Product> Admins { get; set; }
}
}
以及其他库项目中的产品模型
public class Product
{
public Product()
{}
public int Id { get; set; }
[Required]
public string Name { get; set; }
}
我的连接字符串如下
<connectionStrings>
<add name="FBuyShopContext" connectionString="data source=tschikovani\SQLEXPRESS;initial catalog=OnlineShop;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
当我想在控制器的数据库中添加新产品时
FBuyShopContext db = new FBuyShopContext();
Product new = new Product ();
new.Name = "Iphone";
db.Products.Add(new);
db.SaveChanges();
我有以下异常
An exception of type 'System.ArgumentException' occurred in EntityFramework.dll
keyword not supported: 'data source'.
为什么会这样?连接字符串完全正确
【问题讨论】:
标签: entity-framework connection-string