I want to test a very simple Code-First example. I have a class called PurchaseItem
which is not inherited from any based class and also no other class inherits fro
Your connection string might differ from your context! Please check this article.
Entity Framework follows the Convention over Configuration school of thought. This means that even in finding the related connection string, Entity Framework, uses the name of your context class (in this case MiniAccounting
) and tries to find a connection string with that name in the configuration file.
However, if it doesn't find anything, it's fallback to light version of SQL (I guess SQL CE, or SQL Express, not sure about it), creates a database by itself, and tries to insert into it.
In your case, check the configuration file, and see if it matches the name of your context class. If not, user this constructor:
public class MiniContext : DbContext
{
public MiniContext()
: base("YourConnectionStringNameHere")
{
Database.SetInitializer<MiniContext>(null);
}
public DbSet<PurchaseItem> PurchaseItems { get; set; }
}