这个关于EF的代码,为什么报错呢?


public class KTStoreModel : DbContext
{
public KTStoreModel()
: base("name=KTStoreModel")
{
}
public DbSet<Product> Product { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public int Price { get; set; }
public string Category { get; set; }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
KTStoreModel model = new KTStoreModel();
IEnumerable<Product> rows = model.Product.Select(x => x);
int c = model.Product.Count();
MessageBox.Show(c.ToString());
}
上面的代码,使用EF,很简单的代码,为什么报错呢?
翻译了一下,异常提示内容为:SqlException:无法打开登录请求的数据库“WpfApp2.KTStoreModel”。登录失败。
用户“DESKTOP-1S1IHNV\Administrator”登录失败。
VS中不是默认使用LocalDB数据库的吗,自带的呀,为什么会这样
...全文


