This question is locked. New answers and comments are not allowed.
Hi,
I have a mapped class with some string properties. Fluent mapping always results in a schema with "varchar" columns for SQL server.
The documentation states that it is possible to specify "nvarchar" columns as default using the app.config/web.config.
However for my current project I won't be able to use an app.config file.
I've tried to create a default mapping to "nvarchar" in code, but this failed:
So what I'm asking for: how can I create such a default type mapping in code ?
Thank you
Herbert
I have a mapped class with some string properties. Fluent mapping always results in a schema with "varchar" columns for SQL server.
The documentation states that it is possible to specify "nvarchar" columns as default using the app.config/web.config.
However for my current project I won't be able to use an app.config file.
I've tried to create a default mapping to "nvarchar" in code, but this failed:
protected override MetadataContainer CreateModel() { MetadataContainer container = base.CreateModel(); container.DefaultMapping.NullForeignKey = true; container.NameGenerator.UseModelNames = true; container.DefaultMapping.ClrMap.Add(new DefaultTypeMapping() { ClrType = typeof(String).Name, SqlType = "nvarchar", AdoType = OpenAccessType.Varchar }); return container; }So what I'm asking for: how can I create such a default type mapping in code ?
Thank you
Herbert