简体   繁体   中英

Why do we set the “Property” in stored procedure mapping in EF6

I am a novice in EF6. I defined a SP with variables of the input type. In the SP specifies which variable is associated with which column. Then, why do we set the "Property" in stored procedure mapping? Differ? Sp映射

Whats happening is that there is a mapping from the SQL type to the .NET type.

.NET has different types than SQL has.

You can find a list here .

The entity framework will handle the conversions for you.

Here's a part of the table:

SQL Server Database Engine type         .NET Framework type         SqlDbType 
-------------------------------------------------------------------------------
bigint                                 Int64                        BigInt        
binary                                 Byte[]                       VarBinary 
bit                                    Boolean                      Bit       
char                                   String                       Char      
date 1                                 DateTime                     Date 1        
datetime                               DateTime                     DateTime      
datetime2                              DateTime                     DateTime2

As for the naming of the property: EF has some (sometimes annoying) naming conventions.

More on that here: https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/conventions/built-in

And here: Database Naming Conventions by Microsoft?

Take special note to:

"Do not prefix stored procedures with sp_, because this prefix is reserved for identifying system-stored procedures."

https://blogs.msdn.microsoft.com/robcaron/2005/01/27/prefixing-stored-procedure-names-with-sp_/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM