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
;
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
with ObservableCollection
;
- - line - 484 replaced ICollection
with ObservableCollection
;
- - line - 51 replaced HashSet
with ObservableCollection
;
- - lines - 431 replaced System.Collections.Generic
with System.Collections.ObjectModel
;
- Menu Project
//" Add a new data source ";
- Result: the class Student
is present;
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.