This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21034|Reply: 1

[Source] .NET/C# EF FAQ collection

[Copy link]
Posted on 2/4/2018 11:57:47 AM | | |

1. Update EF and can't find the specified table?

The table does not have a primary key set!

2. Have I added an item with the same key?

Reason 1: Check if there are duplicate primary keys!

Reason 2: Check whether the assignment field is duplicated!

Reason 3: The name of the reference foreign key cannot be the same as the table field!

3. Is the rebuild solution successful, but the release fails?

Reason 1: Check whether the .NET Framework version is consistent!

Reason 2: Check if the reference (log4net) is correct!

4. POCO T4 template, failed to generate? (Type or lifespace name not found)

Check if the symbol is wrong (semicolon), it really can't be re-referenced!

5. Cannot update EntitySet "xxx table" because it has a DefiningQuery, and there is no element in the element that supports the current operation?

EF entities do not have a primary key, just delete the rereference!

6. The attribute "state" is part of the key information of the object, cannot be modified?

No primary key, or duplicate primary key!

7. Error when updating entries. For more information, see Internal Exceptions?

The table in the database does not have an identification column, or the data type is wrong!

8. There is no ViewData of type "IEnumerable" with the key "categoryid"<SelectListItem>?

This sentence means: type ViewData does not exist, and its type is IEnumerable<SelectListItem>, and its primary key is categoryid. IEnumerable <SelectListItem>means a collection of SelectListItem.

The solution is: change return View() to return Create()!

9. Verification of one or more entities fails. For more information, see the "EntityValidationErrors" property?

The cause of the problem could be:

1. Non-empty columns do not insert values incorrectly

2. The length of the foreign key column between multiple tables is different      

3. The ef context object db is empty        

4. EF context setting property to db. Configuration.ValidateOnSaveEnabled = false;

5. The content length exceeds the maximum column length

6. The library was added to the solution but not updated

7. Add a reference using System.Data.Validation;

10. The entity type xxx (table) is not part of the model in the current context? / Entity class does not match database field type or attribute?

This table is not in the current database, you need to add a line of code to convert it to another database:

oc.iBllSession.Itb_biaoming_BLL. DbName = "Database Name";

11. Failed to find the type or namespace name"... "(Is there a lack of using instructions or procedures)?"

Delete the original quote, re-quote!




Previous:Very easy to use SMS bomber software
Next:682d7a5cc90aeab75279e71e2464010f How is this encoding implemented?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com