这是我的实体类:
public partial class NerdDinnerEntities : ObjectContext
{
public NerdDinnerEntities(string connectionString)
: base(connectionString, "NerdDinnerEntities")
{
try
{
ObjectContext oc = new ObjectContext(connectionString);
oc.Connection.ChangeDatabase("NERDDINNER1");
oc.AcceptAllChanges();
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
catch (Exception ex) { }
}
partial void OnContextCreated();
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public ObjectSet<Dinner> Dinners
{
get
{
if ((_Dinners == null))
{
_Dinners = base.CreateObjectSet<Dinner>("Dinners");
}
return _Dinners;
}
}
private ObjectSet<Dinner> _Dinners;
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public ObjectSet<RSVP> RSVPs
{
get
{
if ((_RSVPs == null))
{
_RSVPs = base.CreateObjectSet<RSVP>("RSVPs");
}
return _RSVPs;
}
}
private ObjectSet<RSVP> _RSVPs;
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public ObjectSet<sysdiagram> sysdiagrams
{
get
{
if ((_sysdiagrams == null))
{
_sysdiagrams = base.CreateObjectSet<sysdiagram>("sysdiagrams");
}
return _sysdiagrams;
}
}
private ObjectSet<sysdiagram> _sysdiagrams;
/// <summary>
/// Deprecated Method for adding a new object to the Dinners EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead.
/// </summary>
public void AddToDinners(Dinner dinner)
{
base.AddObject("Dinners", dinner);
}
/// <summary>
/// Deprecated Method for adding a new object to the RSVPs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead.
/// </summary>
public void AddToRSVPs(RSVP rSVP)
{
base.AddObject("RSVPs", rSVP);
}
/// <summary>
/// Deprecated Method for adding a new object to the sysdiagrams EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead.
/// </summary>
public void AddTosysdiagrams(sysdiagram sysdiagram)
{
base.AddObject("sysdiagrams", sysdiagram);
}
}
这些是我的 web.config 文件
<add name="NerdDinnerEntities" connectionString="metadata=res://*/Models.NerdDinner.csdl|res://*/Models.NerdDinner.ssdl|res://*/Models.NerdDinner.msl;provider=System.Data.SqlClient;provider connection string="Data Source=@;Database=NERDDINNER;User ID=@;Password=@@@;MultipleActiveResultSets=True"" providerName="System.Data.EntityClients" />
我收到错误:
不支持指定的方法
在这一行:
oc.Connection.ChangeDatabase("NERDDINNER1");