Database Creation Differences Amongst Language Versions

The issues that come with working with non-English language versions of Visual Studio are becoming more apparent as readers write to me about them. Here is the essential problem that you need to consider when reading this post. I strongly endorse use of the downloadable source when working with one of my books. Using the downloadable source means that you don’t have to worry about problems with internationalization or with typos for that matter. All you need to do is load the example into your copy of Visual Studio and follow along as you read the book.

However, many people learn by doing and that’s when problems come into play. If you recreate the examples from scratch, you could encounter problems that have nothing to do with your programming skills or your ability to follow directions. In this case, the problem isn’t the fault of the reader, but of Visual Studio. Databases are created differently by the Entity Framework designer when working with various language versions.

A German reader was kind enough to send me some screenshots of a particular issue that I don’t discuss in the book because I was unaware of it when I wrote it (and a lack of international beta readers kept me from learning about it until now). If you look at the Entity SQL example that begins in the “Creating a basic query using Entity SQL” section of Chapter 4 (page 86), you see that the code interacts with the Customers table. You create this table earlier in the book and it should appear as Customers in SQL Server Management Studio. However, it doesn’t appear under that name if you’re working with the German version of Visual Studio. The IDE appends the word Satz (set) to the table name as shown here (all screenshots are courtesy of my German reader):

TableCreation01

Consequently, when you try to create the code shown on page 87, it doesn’t work. It would work if the table had the right name or if the code used the right name, but the two are out of sync. In order to make this example work, you must change the example code as shown here:

TableCreation02

Of course, making the code change (circled in red) does solve the problem, but it’s not something the developer should have to deal with. In addition, consider how things will work if you’re interacting with a number of team members in different countries—all of whom are using their own language versions of Visual Studio. The resulting chaos must be impressive indeed.

The true source of the problem is the Entity Framework Designer. When you initially create your design, the name of the entity might be Customers, but the Properties window will automatically add Satz to the name for you as shown here:

TableCreation03

To make the book examples work as they appear in the book, you need to ensure that the entity names match those in the book. In this case, all you need to do is remove the Satz part of the name.

Unfortunately, these sorts of problems will continue to crop up with various languages. I’d like to hear about them because knowing what could happen will help me write better books in the future and to provide updates to you here. I really appreciate all of the help my German reader provided in this case. Contact me with any other language-specific glitches you find at John@JohnMuellerBooks.com.

 

DateTimePicker Control Data Type Mismatch Problem

A reader recently made me aware of a problem with the Get User Favorites example in Chapter 2 that could cause a lot of problems depending on which language you use when working with Visual Studio 2012. This issue does affect some of the examples in Microsoft ADO.NET Entity Framework Step by Step so it’s really important you know about it.

Look at the model on page 30 of the book (the “Creating the model” section of Chapter 2). The Birthday field is defined as type DateTime. When you finish creating the model, you right click the resulting entity and choose Generate Database from Model to create a database from it. The “Working with the mapping details” section of Chapter 1 (page 19) tells you how to use the Generate Database Wizard to create the database. The Birthday field in the database will appear as a datetime type when you complete the wizard, which is precisely what you should get.

At this point, you begin creating the example form to test the database (the “Creating the test application” section on page 36). The example uses a DateTimePicker control for the Birthday field by default. You don’t add it, the IDE adds it for you because it sees that Birthday is a datetime data type. The example will compile just fine and you’ll be able to start it up as normal.

However, there is a problem that occurs when working with certain languages when you start the “Running the basic query” section that starts on page 39. The DateTimePicker control appears to send a datetime2 data type back to SQL Server when you change the birthday information. You’ll receive an exception that says the data types don’t match, which they don’t. There are several fixes for this problem. For example, you could coerce the output of the DateTimePicker control to output a datetime data type instead of a datetime2 data type. However, the easiest fix is to simply change the data type of the Birthday field in the database from datetime to datetime2. After you make this change, the example will work as it should. You only need to make this change when you see the data type mismatch exception. I haven’t been able to verify as of yet which languages are affected and would love to hear from my international readers about the issue.

As far as the book is concerned, this problem is quite fixable using the manual edit (although, manually editing the database shouldn’t be something you should have to do). However, it does bring up the question of how teams working across international boundaries will interact with each other if they can’t depend on the controls acting in a particular way every time they’re used. This is a problem that you need to be aware of when working with larger, international, teams. Let me know if you have any questions or concerns about the book example at John@JohnMuellerBooks.com. You’ll have to contact Microsoft about potential fixes to the DateTimePicker control since I have no control over it.