-1
我用实体的代码生成工具在我的数据库,给我的背景下我该怎么处理这个生成的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 LRVault.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class LRC_VAULTEntities : DbContext
{
public LRC_VAULTEntities()
: base("name=LRC_VAULTEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Post> Posts { get; set; }
public virtual DbSet<Thread> Threads { get; set; }
}
}
,我希望能够马上使用它像
var context = new LRC_VAULTENtities();
context.Posts.InsertOnSubmit(new Post() { ... });
context.Posts.SubmitChanges();
但是没有Posts
属性创建后RC_VAULTENtities
的实例。那么我该怎么做?
貌似LRC_VAULTEntities'和'LRC_VAULTENtities'之间'拼写出现错误代码显示,在的DbContext – Nkosi
@Nkosi'存在Posts'财产,不,这不是问题 –
@DeadlyNicotine嗯,有一个错字的地方 - 因为这根本不一定与EF有关。你已经明确声明'Posts'是一个属性,所以你几乎肯定会引用错误的类。 – Rob