Quantcast
Channel: Effort - Entity Framework Unit Testing Tool
Viewing all articles
Browse latest Browse all 111

Created Unassigned: Have to manually update context class every time [761]

$
0
0
When using Effort, it requires an interface to be used in the context class, such as in MyAppContext.cs:

```
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestingEf.Data.Entities
{
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Common;

public partial class MyAppContext : DbContext, IMyAppContext
{
/// <summary>
/// Constructs a new context instance with the default connection string.
/// </summary>
public MyAppContext()
: base("name=MyAppContext")
{
this.Configuration.LazyLoadingEnabled = false;
}

/// <summary>
/// Constructs a new context instance using the given string as the name or connection
/// string for the database to which a connection will be made. See the DbContext class
/// remarks for how this is used to create a connection.
/// </summary>
/// <param name="nameOrConnectionString">Either the database name or a connection string.</param>
public MyAppContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
this.Configuration.LazyLoadingEnabled = false;
}

/// <summary>
/// Constructs a new context instance using the given DbConnection.
/// The given connection will be disposed when this instance is disposed
/// </summary>
/// <param name="connection">The connection to create the context with</param>
public MyAppContext(DbConnection connection)
: base(connection, true)
{
this.Configuration.LazyLoadingEnabled = false;
}

public IDbSet<Product> Products { get; set; }
public IDbSet<ProductTag> ProductTags { get; set; }
public IDbSet<Tag> Tags { get; set; }

}
}

```

The problem is, every time I update the EDMX model from changes in the SQL Server database, it also re-generates the MyAppContext.cs file, so the IMyAppContext gets blown away.

![Image](http://imgur.com/HHvZ2Vz)

Is there any way to resolve this issue so that I don't have to re-add the IMyAppContext every time I update the EDMX model from the database?

Viewing all articles
Browse latest Browse all 111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>