Linq错误:不包含'InsertOnSubmit'的定义

时间:2013-12-10 06:51:53

标签: c# asp.net entity-framework

我有以下代码:

   public static bool Update(UserExtendedData data, byte[] image)
        {

            data.UserId = getUserId_new();

            IQueryable<UserExtendedData> entry = m_model.UserExtendedDataSet.Where(x => x.UserId == getUserId_new());
            UserExtendedData User = entry.Single();
            User.firstName = data.firstName;
            User.lastName = data.lastName;
            User.phoneNo = data.phoneNo;
            User.creditCardNo = data.creditCardNo;
            User.dateOfBirth = data.dateOfBirth;
            User.UserId = getUserId_new();

            if (image != null)
            {
                User.avatarArt = image;
            }
            m_model.UserExtendedDataSet.InsertOnSubmit(data);

            return true;
        }

我已经使用System.Data.Linq;我在Windows 7(x64)上使用asp.net 4.5 我还包括:

 <compilation debug="true" targetFramework="4.5">

但我仍然有错误:

does not contain a definition for 'InsertOnSubmit' and no extension method 'InsertOnSubmit' accepting a first argument of type ' could be found (are you missing a using directive or an assembly reference?) 

但奇怪的是我没有遇到任何问题:

public static bool Insert(UserExtendedData data, byte[] image)
        {

            data.UserId = getUserId_new();

                if (image != null)
                    data.avatarArt = image;

                m_model.UserExtendedDataSet.Add(data) ;
                m_model.SaveChanges();
                return true;
        }

您有什么想法会导致这个问题吗?我真的很感激任何帮助。

1 个答案:

答案 0 :(得分:1)

你的Entity set file extension是什么?如果是dbml那么它将在dbmx

的情况下起作用

Reference