Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8941049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:12:29+00:00 2026-06-15T11:12:29+00:00

I cannot find a way to perform a insert statement using EF. Many error

  • 0

I cannot find a way to perform a insert statement using EF.

Many error have emerged.

The code is all here and the problem is with the controller: I have alread tried:

context.sistema_UsersCertified.Add(uc);
context.Set<sistema_UsersCertified>().Add(uc);

It says that sistema_UsersCertified has some invalid argumments

why?

This is my dbcontext:

public partial class tgpwebgedEntities : DbContext
{
    public tgpwebgedEntities()
        : base("name=tgpwebgedEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }

    public DbSet<sistema_UsersCertified> sistema_UsersCertified { get; set; }

}

This table has 4 collumns: id(int), userID(Guid), certTypeID(int), keyNumber(string)

so I have created a Model based in that table:

   public class UsersCertified
{
    public Guid userId;
    public int certTypeId;
    public string keyNumber;

    public UsersCertified(Guid uId, int ctId, string kn) {
        userId = uId;
        certTypeId = ctId;
        keyNumber = kn;
    }
}

and I have a viewthat send data to a controller:

<table>
                    <tr>
                    <td style="font-size:10px;">Habilitar Login com Cert. Digital:</td>
                    <td>@Html.CheckBoxFor(m => m.isCertified)</td>
                    </tr>
                    <tr>
                        <td class="smallField">Tipo do Certificado:</td>
                        <td>@Html.DropDownListFor(m => m.certType, new SelectList(ViewBag.certType, "id","type"))</td>
                    </tr>
                    <tr>
                        <td>Identificação:</td>
                        <td>@Html.TextBoxFor(m => m.identifier, new { @class = "validate[required]" }) @Html.ValidationMessage("awnserVal", "*")</td>
                    </tr> 
                </table>

and the last.. my controller:

using (tgpwebgedEntities context = new tgpwebgedEntities()) {
                {
 var userID = from u in context.aspnet_Users where u.UserName == model.UserName select u.UserId;
                    Guid uID = userID.First();
UsersCertified uc = new UsersCertified(uID, model.certType, model.identifier);

//HERE I NEED SET MY TABLE WITH MY MODEL... BUT SO MANY ERROR

   context.SaveChanges();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:12:30+00:00Added an answer on June 15, 2026 at 11:12 am

    Oh I think it may be that you are creating a model of type UsersCertified and then trying to save it as a database entity of type sistema_UsersCertified.

    Try

    sistema_UsersCertified dbEntity = new sistema_UsersCertified();
    dbEntity.CertType = ...
    context.sistema_UsersCertified.Add(dbEntity);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many (most? nearly all?) SQL dialects have a way to perform this type of
I have a few things that I cannot find a good way to perform
I cannot seem to find a way to have LINQ return the value from
My problem is that I cannot find a way to correctly display the correct
I have the following method in my AppDelegate. I cannot find a way to
I cannot find a way to get a Book's Ratings through the Books API
Probably a silly question but I cannot find a way to do it. I
i want to update my sqlite database but i cannot find the way to
sorry for the dummy question but I cannot find a simple and clean way
I am stuck on this issue and cannot seem to find a way around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.