How to "Add a new data source" in a WPF Core application?

c# entity-framework entity-framework-core wpf wpf-core

Question

Question: How to "Add a new data source" in a WPF Core application?  
I performed:
 - Created a WPF Core application;
 - Added the class CntDBSchool;
 - Added the class Student;
 - Menu Project //" Add a new data source ";
 - Result: there is no class Student;
  enter image description here

enter image description here

Class CntDBSchool.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;
 
namespace WpfApp.Models
{
    class CntDBSchool: DbContext
    {
        public virtual DbSet <Student> Student {get; set; }
    }
}

Class Student.

using System;
using System.Collections.Generic;
using System.Text;
 
namespace WpfApp.Models
{
    class Student
    {
        public int StudentID {get; set; }
        public string StudentName {get; set; }
        public Nullable <int> StandardId {get; set; }
        public byte [] RowVersion {get; set; }
    }
}

  Table Student.

 CREATE TABLE [dbo]. [Student] (
  [StudentID] int IDENTITY (1,1) NOT NULL,
  [StudentName] varchar (50) COLLATE Latin1_General_CI_AI NULL,
  [StandardId] int NULL,
  [RowVersion] timestamp NOT NULL,
  CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED ([StudentID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY],
  CONSTRAINT [FK_Student_Standard] FOREIGN KEY ([StandardId]) REFERENCES [dbo]. [Standard] ([StandardId]) ON DELETE CASCADE ON UPDATE NO ACTION
)
ON [PRIMARY]

    When I do the same in the WPF Framework application, the Student class is present in the Add New Data Source window.
I do:
 - Created a WPF Framework application;
 - Created Model ADO.NET EDM;
 - In the file DBModel.tt replaced:
 - - line - 296 replaced ICollection withObservableCollection;
 - - line - 484 replaced ICollection withObservableCollection;
 - - line - 51 replaced HashSet withObservableCollection;
 - - lines - 431 replaced System.Collections.Generic withSystem.Collections.ObjectModel;
 - Menu Project //" Add a new data source ";
 - Result: the class Student is present;
enter image description here enter image description here

1
3
11/1/2019 9:34:10 PM

Popular Answer

Ran into this today too. Adding A datasource with a WPF Framework application works but adding a datasource with WPF Core application doesn't work. I found that someone submitted an issue back in July of 19' https://github.com/dotnet/wpf/issues/1196. They racked it up to not all features work with core.

2
1/11/2020 1:21:59 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow