Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Unassigned: [Investigate EF6] Designer: Designer: update model from database broken [1543]

$
0
0
Using the sql compact provider it is fairly easy to break a lot of the mappings for the model and to get the model in a state where it won't update from the database

Repro:
* Install packages from aspnet nightly and main feed
```
PM> Install-Package entityframework.Sqlservercompact -pre -version 6.0.0-rc1-20807
PM> Install-Package ChinookDatabase.SqlServerCompact
```
* Build
* Add new ADO.NET Entity Data Model generated from Chinook.sdf
* update program.cs as shown below
* from designer surface: Generate Database from Model then save the script
* add image column to Album table in chinook.sdf
* from designer surface: update model from database
* NOTE: in the error list there are a bunch of broken mappings and the model isn't updated to match database changes


program.cs:
```
using System;

namespace DesignerRetarget
{
class Program
{
static void Main(string[] args)
{
using (var db = new ChinookEntities())
{
Console.WriteLine("Album");
foreach (var album in db.Albums)
{
Console.WriteLine(album.Title + " by " + album.Artist.Name);
}

Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
}
}
}

```
Comments: Resolving as "By Design" - in general when creating a SQL script from the model we regenerate SSDL and MSL based on CSDL (which might have been modified) which means we change the model. Since the database was not created from the generated script trying to update the model is like trying to update a random model since the model and the database are no longer in sync. When closing please verify that if the user creates the database from the generated script update model works as advertised. (This does not have to be done with Sql Ce as the scenario described here is db independent)

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>