-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RelationshipDiscoveryConvention rediscovers entity while it is being ignored #3845
Comments
Hey, I haven't been able to reproduce this. Below is the model I have been using and ~Rowan using Microsoft.Data.Entity;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Spatial;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (var db = new BloggingContext())
{
db.Blogs.Add(new Blog { Id = 22, Url = "blogs.msdn.com/dotnet" });
db.SaveChanges();
}
}
}
public class Blog
{
public int Id { get; set; }
public string Url { get; set; }
[NotMapped]
public NotifyTaskCompletion<Geometry> StartImage
{
get; set;
}
}
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Repro;Trusted_Connection=True;");
}
}
public sealed class NotifyTaskCompletion<TResult> : INotifyPropertyChanged
{
public NotifyTaskCompletion(Task<TResult> task)
{
Task = task;
if (!task.IsCompleted)
{
TaskCompletion = WatchTaskAsync(task);
}
}
private async Task WatchTaskAsync(Task task)
{
try
{
await task;
}
catch { }
var propertyChanged = PropertyChanged;
if (propertyChanged == null) return;
propertyChanged(this, new PropertyChangedEventArgs("Status"));
propertyChanged(this, new PropertyChangedEventArgs("IsCompleted"));
propertyChanged(this, new PropertyChangedEventArgs("IsNotCompleted"));
if (task.IsCanceled)
{
propertyChanged(this, new PropertyChangedEventArgs("IsCanceled"));
}
else if (task.IsFaulted)
{
propertyChanged(this, new PropertyChangedEventArgs("IsFaulted"));
propertyChanged(this, new PropertyChangedEventArgs("Exception"));
propertyChanged(this, new PropertyChangedEventArgs("InnerException"));
propertyChanged(this, new PropertyChangedEventArgs("ErrorMessage"));
}
else
{
propertyChanged(this, new PropertyChangedEventArgs("IsSuccessfullyCompleted"));
propertyChanged(this, new PropertyChangedEventArgs("Result"));
}
}
public Task<TResult> Task { get; private set; }
public Task TaskCompletion { get; private set; }
public TResult Result { get { return (Task.Status == TaskStatus.RanToCompletion) ? Task.Result : default(TResult); } }
public TaskStatus Status { get { return Task.Status; } }
public bool IsCompleted { get { return Task.IsCompleted; } }
public bool IsNotCompleted { get { return !Task.IsCompleted; } }
public bool IsSuccessfullyCompleted { get { return Task.Status == TaskStatus.RanToCompletion; } }
public bool IsCanceled { get { return Task.IsCanceled; } }
public bool IsFaulted { get { return Task.IsFaulted; } }
public AggregateException Exception { get { return Task.Exception; } }
public Exception InnerException { get { return (Exception == null) ? null : Exception.InnerException; } }
public string ErrorMessage { get { return (InnerException == null) ? null : InnerException.Message; } }
public event PropertyChangedEventHandler PropertyChanged;
}
} |
Hi Rowan, Thanks for working on this problem! Your example worked for me too. I managed to get it to freeze up by adding a second [NotMapped] as below. Ryan
|
Thanks! I see the hang on RC1. On our latest nightly it does not hang, but you now get the following error during
Here is the code stripped down to the smallest code that produces the issue. using Microsoft.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Spatial;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (var db = new BloggingContext())
{
db.Blogs.Add(new Blog { Id = 22, Url = "blogs.msdn.com/dotnet" });
db.SaveChanges();
}
}
}
public class Blog
{
public int Id { get; set; }
public string Url { get; set; }
[NotMapped]
public bool IsWeight { get; set; }
[NotMapped]
public Task<Geometry> StartImage { get; set; }
}
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data source=GymBuilder.db");
}
}
} |
I was playing around with async loading, and added the follow method to one of my Models:
When I tried to add a migration (Add-Migration), the command never completed, and just kept chewing through CPU.
NotifyTaskCompletion is as follows:
The text was updated successfully, but these errors were encountered: