Entity Framework and nvarchar

0

When the Entity Framework creates fields by default in a table of type string, use nvarchar . But I understand that nvarchar takes more space than varchar . Can the use of nvarchar double the size of a table? Is it recommended the nvarchar or choose the varchar from the Fluent API? Are we talking about the code-first approach?

    
asked by Pedro Ávila 22.08.2016 в 19:26
source

1 answer

0

Actually nvarchar allows defining extended characters of unicode .

The "N" in NVARCHAR means uNicode. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. What would represent a maximum length of 4000 characters. What it means to have the ability to store special characters in this type of data.

Let's summarize the differences:

  • VARCHAR maximum allowed length: 8000 characters. MAX NVARAR     Allowed length: 4000 characters.
  • VARCHAR stores single-byte characters of extended ASCII type. NVARCHAR Ability to store two-byte characters. Characters     Unicode
  • Because of the above, disk storage will be twice as much in NVARCHAR than VARCHAR
  • Source: Difference between Varchar and Nvarchar

    > > Is it advisable to nvarchar or choose varchar from the Fluent API?

    It depends on what type of text you need to store, if you're going to persist accents or the ñ , if you're just going to persist simple characters would not be necessary

        
    answered by 22.08.2016 / 19:39
    source