I have an application that I tied to a DB for loading and storing data.
However I don't want to require the user to be on the network and have access to the DB. It just can't load or save without a connection.
I would like to instantiate it without a db connection (just use it in memory), but all constructors use the DB. I would prefer not to modify the entity framework generated .cs file in case I need to update it again from the DB I don't want to wipe out my changes.
How can I use the EF model without a connection?
public partial class SimRunnerEntities : ObjectContext
{
#region Constructors
/// <summary>
/// Initializes a new SimRunnerEntities object using the connection string found in the 'SimRunnerEntities' section of the application configuration file.
/// </summary>
public SimRunnerEntities() : base("name=SimRunnerEntities", "SimRunnerEntities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
/// <summary>
/// Initialize a new SimRunnerEntities object.
/// </summary>
public SimRunnerEntities(string connectionString) : base(connectionString, "SimRunnerEntities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
/// <summary>
/// Initialize a new SimRunnerEntities object.
/// </summary>
public SimRunnerEntities(EntityConnection connection) : base(connection, "SimRunnerEntities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
All SimRunnerEntities constructors use some sort of valid connection