私はデータベースを最初にやっていて、EFはCode First DbContextサブクラスを生成しました...
//------------------------------------------------------------------------------
// <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 Glossary.UI.Database
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class GlossaryDb : DbContext
{
public GlossaryDb()
: base("name=GlossaryDb")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<GlossaryTerm> GlossaryTerms { get; set; }
}
}
ご覧のとおり、例外がスローされているため、コードが再生成されるたびにこれをコメントアウトする必要があります! さらに要点を言えば、なぜこのクラスが生成されたのでしょうか。