日期:2014-05-17  浏览次数:21143 次

c#把目标框架从.net framework4.5改成4出错
本帖最后由 realdrizzt 于 2014-01-20 08:12:25 编辑
错误 1 “WindowsFormsApplication2.Model1Container”的分部声明一定不能指定不同的基类 D:\autofill\WindowsFormsApplication2\Model1.Context.cs 16 26 WindowsFormsApplication2
错误 2 类型“WindowsFormsApplication2.Model1Container”已定义了一个名为“Model1Container”的具有相同参数类型的成员 D:\autofill\WindowsFormsApplication2\Model1.Designer.cs 34 16 WindowsFormsApplication2
这是Model1.Context.cs文件内容
//------------------------------------------------------------------------------
// <auto-generated>
//    此代码是根据模板生成的。
//
//    手动更改此文件可能会导致应用程序中发生异常行为。
//    如果重新生成代码,则将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------

namespace WindowsFormsApplication2
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;
    
    public partial class Model1Container : DbContext
    {
        public Model1Container()
            : base("name=Model1Container")
        {
        }
    
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
    
    }
}

这是Model1.Designer.cs文件内容
//------------------------------------------------------------------------------
// <auto-generated>
//    此代码是根据模板生成的。
//
//    手动更改此文件可能会导致应用程序中发生异常行为。
//    如果重新生成代码,则将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Data.EntityClient;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml.Serialization;

[assembly: EdmSchemaAttribute()]
namespace WindowsFormsApplication2
{
    #region 上下文
    
    /// <summary>
    /// 没有元数据文档可用。
    /// </summary>
    public partial class Model1Container : ObjectContext
    {
        #region 构造函数
    
        /// <summary>
        /// 请使用应用程序配置文件的“Model1Container”部分中的连接字符串初始化新 Model1Container 对象。
        /// </summary>
        public Model1Container() : base("name=Model1Container", "Model1Container")