我想扩大这个线程问的问题
通过赋予它持久化数据的能力。除了我安装了Entity Framework Core,创建了一个DbContext
用于保存记录的类之外,该结构基本相同。我添加了一个按钮来将数据集保存到SQL Server。我没有遇到编译错误,但是当我尝试将数据保存到数据库中时,出现了此运行时异常:
Message =实体类型“ Fruit”要求定义主键。
下面列出了整个异常的整体
未处理System.InvalidOperationException
HResult = -2146233079
消息=实体类型“水果”要求定义主键。
源= Microsoft.EntityFrameworkCore
堆栈跟踪:
在Microsoft.EntityFrameworkCore.Internal.ModelValidator.ShowError(字符串消息)
在Microsoft.EntityFrameworkCore.Internal.ModelValidator.EnsureNonNullPrimaryKeys(IModel模型)
在Microsoft.EntityFrameworkCore.Internal.ModelValidator.Validate(IModel模型)
在Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel上的Microsoft.EntityFrameworkCore.Internal.RelationalModelValidator.Validate(IModel模型)
(DbContext上下文,IConventionSetBuilder ConventionSetBuilder,IModelValidator验证器)
在Microsoft.EntityFrameworkCore.Infrastructure.ModelSource。<> c__DisplayClass14_0.b__0(对象k)
在System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func
2 valueFactory)
在Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(的DbContext上下文,IConventionSetBuilder conventionSetBuilder,IModelValidator验证器)
在Microsoft.EntityFrameworkCore.Internal.LazyRef 2上的Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()2.Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSiteProvider )
上的VisitCallSite(IServiceCallSite callSite,TArgument参数 )1.get_Value()
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServiceCollectionExtensions.<>c.<AddEntityFramework>b__0_6(IServiceProvider p)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactoryService(FactoryService factoryService, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopes (ScopedookSite scopedCallSite,ServiceProvider提供者.VisitCallSite(IServiceCallSite callSite,TArgument参数) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor 2。存取器) 在Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.get_StateManager() 在Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.DetectChanges() 在Microsoft.EntityFrameworkCore.DbContext.TryDetectChanges() 在Microsoft.EntityFrameworkCore.DbContext.SaveChanges(布尔acceptAllChangesOnSuccess)2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure
在
Fruits.MainWindow.SaveFruitCommandBinding_Executed(Object sender,ExecutedRoutedEventArgs e)在Microsoft.EntityFrameworkCore.DbContext.SaveChanges()在System.Windows.Input D:\ Frank \ Test \ Fruits \ Fruits \ MainWindow.xaml.cs:line 50
中。 CommandBinding.OnExecuted(对象发件人,ExecutedRoutedEventArgs E)
在System.Windows.Input.CommandManager.ExecuteCommandBinding(对象发件人,ExecutedRoutedEventArgs E,的CommandBinding的CommandBinding)
在System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection化CommandBindings,对象发件人,RoutedEventArgs E,
System.Windows.Input.CommandManager.FindCommandBinding上的ICommand命令,布尔执行)(对象发送者,RoutedEventArgs e,ICommand命令,布尔执行)
在System.Windows.Input.CommandManager.OnExecuted(对象发件人,ExecutedRoutedEventArgs e)在System.Windows.UIElement.OnExecutedThunk(对象发件人,ExecutedRoutedEventArgs e)在System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(委托GenericHandler,对象目标) System.System.Windows.EventRoute.InvokeHandlersImpl(系统中的Object source,RoutedEventArgs args,Boolean重新引发)处的System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,RoutedEventArgs routedEventArgs)处的System.Windows.RoutedEventArgs.InvokeHandler(代理处理程序,对象目标)。 Windows上的Windows.UIElement.RaiseEventImpl(DependencyObject sender,RoutedEventArgs args)System.Windows.UIElement.RaiseEvent(RoutedEventArgs args,Boolean Trusted)。MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource)的System.Windows.Input.RoutedCommand.ExecuteCore(Object参数,IInputElement目标,布尔userInitiated) ,在System.Windows.Controls.Primitives.ButtonBase.OnClick()在System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)在System.Windows.Controls.Primitives.ButtonBase.OnClick() .UIElement.OnMouseLeftButtonUpThunk(Object sender,MouseButtonEventArgs e)在System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler,Object genericTarget)在System.Windows。System.Windows.EventRoute.InvokeHandlersImpl(System.Windows.EventRoute.InvokeHandlersImpl(Object source,RoutedEventArgs args,Boolean reRaised)处System.Windows.Route。在System.Windows.UIElement.OnMouseUpThunk(对象发件人,MouseButtonEventArgs e)在System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(委托GenericHandler,Object genericTarget)在System.Windows.RoutedEventArgs处的ReRaiseEventAs(DependencyObject sender,RoutedEventArgs args,RoutedEvent newEvent)。 System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,处的InvokeHandler(代理处理程序,对象目标)System.Windows.EventRoute.InvokeHandlersImpl(Object source,RoutedEventArgs args,Boolean reRaised)at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender,RoutedEventArgs args)at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs Arg) System.Windows.Input.InputManager.ProcessStagingArea()的System.Windows.Input.InputManager.ProcessInput(InputEventArgs输入)的System.Windows.Input.Input.InputProvider.item(RoutedEventArgs args,布尔值受信任) System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd,InputMode模式,Int32时间戳,RawMouseActions操作,Int32 x,Int32 y,System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd,WindowMessage msg,IntPtr wParam,IntPtr lParam,布尔值和处理)处的Int32滚轮)位于System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd,Int32 msg,IntPtr wParam MS.Win32.HwndWrapper.WndProc(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,布尔值和已处理)在MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)在System.Windows.Threading.ExceptionWapper System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback,Object args,Int32 numArgs,Delegate catchHandler)在System.Windows.Threading.Dispatcher处的InternalRealCall(Delegate回调,Object args,Int32 numArgs)。LegacyInvokeImpl(DispatcherPriority优先级,TimeSpan超时,委托方法,对象args,Int32 numArgs)位于MS.Win32.UnMSGMethod()上的MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParamative)在MS.Win32.Un在System.Windows.Application.RunDispatcher(对象忽略)在System.Windows.Application.RunInpatcher(对象忽略)在System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame框架)窗口)在System.Windows.Application.Run(窗口窗口)在System.Windows.Application.Run()在Fruits.App.Main()在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,System.AppDomain.ExecuteAssembly中的String [] args(系统上System.Threading.ThreadHelper.ThreadStart_Context(对象状态)处的Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()处的String.FileDomain.ExecuteAssembly(String System.Threading.ExecutionContext.Run(ExecutionContext.RunInternal(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔类型的saveSyncCtx)位于System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔类型saveSyncCtx) ,ContextCallback回调,对象状态)位于System.Threading.ThreadHelper.ThreadStart()InnerException:Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()处的ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)在System.Threading.ExecutionContext.RunInternal(ExecutionContext executeContext,ContextCallback处的System.Threading.ThreadHelper.ThreadStart_Context(Object state)处在System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔值saveSyncCtx)在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态)处的回调。 Threading.ThreadHelper.ThreadStart()InnerException:Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()处的ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)在System.Threading.ExecutionContext.RunInternal(ExecutionContext executeContext,ContextCallback处的System.Threading.ThreadHelper.ThreadStart_Context(Object state)处在System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔值saveSyncCtx)在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态)处的回调。 Threading.ThreadHelper.ThreadStart()InnerException:System.Threading.ThreadHelper.ThreadStart_Context(对象状态)位于System.Threading.ExecutionContext.RunInternal(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔状态保持同步Ctx) System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔类型的saveSyncCtx)在System.Threading.ThreadHelper.ThreadStart()处的异常(ExecutionContext executeContext,ContextCallback回调,对象状态)InnerException:System.Threading.ThreadHelper.ThreadStart_Context(对象状态)位于System.Threading.ExecutionContext.RunInternal(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔状态保持同步Ctx) System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔类型的saveSyncCtx)在System.Threading.ThreadHelper.ThreadStart()处的异常(ExecutionContext executeContext,ContextCallback回调,对象状态)InnerException:System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔类型保持SyncCtx)在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔回调SyncCtx)对象状态),位于System.Threading.ThreadHelper.ThreadStart()InnerException:System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔类型保持SyncCtx)在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔回调SyncCtx)对象状态),位于System.Threading.ThreadHelper.ThreadStart()InnerException:对象状态),位于System.Threading.ThreadHelper.ThreadStart()InnerException:System.Threading.ThreadHelper.ThreadStart()的InnerException对象状态:
这是更新的类Fruit:
namespace Fruits.ViewModels
{
[Table("Fruits")]
public class Fruit : ViewModelBase
{
#region Constractor
public Fruit()
{
}
public Fruit(string name, String clrString)
{
FruitName = name;
// Parse colors like so: (Color)ColorConverter.ConvertFromString(clrString);
FruitColor = clrString;
_id = Guid.NewGuid();
}
public Fruit(string name, Color clr)
{
FruitName = name;
FruitColor = clr.ToString();
_id = Guid.NewGuid();
}
#endregion
#region Properties
private Guid _id;
[Key]
public Guid ID
{
get { return _id; }
}
#region FruitName
private string _fruitname;
public string FruitName
{
get
{
return _fruitname;
}
set
{
if (_fruitname != value)
{
_fruitname = value;
OnPropertyChanged("FruitName");
}
}
}
#endregion
#region FruitColor
private String _fruitcolor;
public String FruitColor
{
get
{
return _fruitcolor;
}
set
{
if (_fruitcolor != value)
{
_fruitcolor = value;
OnPropertyChanged("FruitColor");
}
}
}
#endregion
#region Selected Property
private bool _isSelected = true;
// NOTE: I renamed this property
public bool IsSelected
{
get
{
return _isSelected;
}
set
{
if (_isSelected != value)
{
_isSelected = value;
OnPropertyChanged("IsSelected");
}
}
}
#endregion
#endregion
}
}
更新的MainWindows xaml(添加保存按钮)
<Window x:Class="Fruits.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Fruits"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<RoutedCommand x:Key="AddFruit" />
<RoutedCommand x:Key='SaveFruit' />
</Window.Resources>
<Window.CommandBindings>
<CommandBinding Command='{StaticResource AddFruit}'
Executed='AddFruitCommandBinding_Executed'
CanExecute='AddFruitCommandBinding_CanExecute' />
<CommandBinding Command='{StaticResource SaveFruit}'
Executed='SaveFruitCommandBinding_Executed'
CanExecute='SaveFruitCommandBinding_CanExecute' />
</Window.CommandBindings>
<Grid>
<StackPanel Orientation='Vertical'
Margin='10'>
<CheckBox IsChecked="{Binding ShowSelectedFruitOnly}">Selected Fruit Only</CheckBox>
<ListBox x:Name='MyList'
ItemsSource="{Binding FruitsView}"
ItemTemplate='{StaticResource FruitTemp}' />
<StackPanel Orientation="Horizontal"
Margin="0,10,0,0">
<Label Width="100">New Name:</Label>
<TextBox Width="200"
Text="{Binding NewFruitName, Mode=TwoWay }"
/>
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,10,0,0">
<Label Width="100">New Color:</Label>
<!--<TextBox Width="200"
Text="{Binding NewFruitColor, UpdateSourceTrigger=PropertyChanged}" />-->
<TextBox Width="200"
Text="{Binding NewFruitColor, Mode=TwoWay }" />
<ContentControl Style="{StaticResource ColorSwatch}"
Margin="2"
VerticalAlignment="Center"
Content="{Binding NewFruitColor}" />
</StackPanel>
<StackPanel Orientation='Horizontal'>
<Button x:Name='AddFruit'
Height='auto'
Width='auto'
Content='Add New Fruit 2'
Margin='0,10,0,0'
Command='{StaticResource AddFruit}' />
<Button x:Name='SaveFruit'
Height='auto'
Width='auto'
Content='Save Fruit'
Margin='100,10,0,0'
Command='{StaticResource SaveFruit}' />
</StackPanel>
</StackPanel>
</Grid>
</Window>
和我在mainwindows后面的代码(添加了处理程序)
using Fruits.ViewModels;
using System;
using System.Windows;
using System.Windows.Input;
namespace Fruits
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new MainViewModel();
ViewModel.AddNewFruit("Jackfruit", "Yellow");
ViewModel.AddNewFruit("Watermelon", "ForestGreen");
ViewModel.AddNewFruit("Apple", "Red");
ViewModel.AddNewFruit("Banana", "Yellow");
ViewModel.AddNewFruit("Orange", "DeepSkyBlue");
//ViewModel.Fruits[0].IsSelected = false;
//ViewModel.Fruits[1].IsSelected = false;
ViewModel.FruitsView.Refresh();
}
public MainViewModel ViewModel { get { return DataContext as MainViewModel; } }
private void AddFruitCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
ViewModel.AddNewFruit();
}
private void AddFruitCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute =
ViewModel != null
&& !String.IsNullOrWhiteSpace(ViewModel.NewFruitName)
&& !String.IsNullOrWhiteSpace(ViewModel.NewFruitColor)
;
}
private void SaveFruitCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
using (var db=new FruitDbContext())
{
db.SaveChanges();
}
}
private void SaveFruitCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
}
}
我新添加的dbContext:
namespace Fruits.ViewModels
{
public class FruitDbContext:DbContext
{
public DbSet<Fruit> Fruits { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionBuilder)
{
optionBuilder.UseSqlServer(@"Server = xxx; Database=Test; Integrated Security = True");
}
}
}
其他类别保持不变,但无论如何我都列出了它们:
ViewModelBase
namespace Fruits.ViewModels
{
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
}
ViewModel
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Data;
using System.Windows.Media;
namespace Fruits.ViewModels
{
#region MainViewModel Class
public class MainViewModel : ViewModelBase
{
public MainViewModel()
{
Fruits = new ObservableCollection<Fruit>();
}
public ICollectionView FruitsView { get; private set; }
#region ShowSelectedFruitOnly Property
private bool _showSelectedFruitOnly = true;
public bool ShowSelectedFruitOnly
{
get { return _showSelectedFruitOnly; }
set
{
if (value != _showSelectedFruitOnly)
{
_showSelectedFruitOnly = value;
FruitsView.Refresh();
OnPropertyChanged("ShowSelectedFruitOnly");
}
}
}
#endregion ShowSelectedFruitOnly Property
#region Add Methods
public void AddNewFruit()
{
Fruits.Add(new Fruit(NewFruitName, NewFruitColor));
NewFruitName = "";
NewFruitColor = "";
}
public void AddNewFruit(string name, string color)
{
Fruits.Add(new Fruit(name, color));
}
public void AddNewFruit(string name, Color color)
{
Fruits.Add(new Fruit(name, color));
}
#endregion Add Methods
#region NewFruitName Property
private String _newFruitName = default(String);
public String NewFruitName
{
get { return _newFruitName; }
set
{
if (value != _newFruitName)
{
_newFruitName = value;
OnPropertyChanged("NewFruitName");
}
}
}
#endregion NewFruitName Property
#region NewFruitColor Property
private String _newFruitColor = default(String);
public String NewFruitColor
{
get { return _newFruitColor; }
set
{
if (value != _newFruitColor)
{
_newFruitColor = value;
OnPropertyChanged("NewFruitColor");
}
}
}
#endregion NewFruitColor Property
#region Fruits Property
private static ObservableCollection<Fruit> _fruits;
public ObservableCollection<Fruit> Fruits
{
get { return _fruits; }
private set
{
if (value != _fruits)
{
_fruits = value;
FruitsView = CollectionViewSource.GetDefaultView(Fruits);
FruitsView.Filter = FruitFilterPredicate;
FruitsView.Refresh();
OnPropertyChanged("Fruits");
}
}
}
protected bool FruitFilterPredicate(Object o)
{
if (ShowSelectedFruitOnly)
{
return (o as Fruit).IsSelected;
}
return true;
}
#endregion Fruits Property
}
#endregion MainViewModel Class
}
应用程式
<Application x:Class="Fruits.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Fruits"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="ColorSwatch"
TargetType="ContentControl">
<Setter Property="Width"
Value="24" />
<Setter Property="Height"
Value="24" />
<Setter Property="IsTabStop"
Value="false" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Rectangle HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Stroke="Gray"
StrokeThickness="1">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding}" />
</Rectangle.Fill>
</Rectangle>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key='FruitTemp'>
<StackPanel Orientation='Horizontal'
Margin='5'>
<TextBlock x:Name='tbName'
Text='{Binding FruitName}'
Margin='10,0,0,0'
Width='100' />
<TextBlock x:Name='tbColor'
Text='{Binding FruitColor}'
Margin='10,0,0,0'
Width='100' />
<ContentControl Width="16"
Height="16"
Style="{StaticResource ColorSwatch}"
Content="{Binding FruitColor}" />
<!-- The problem here was you were trying to bind Checked, an event,
instead if IsChecked, a bool? property.
-->
<CheckBox x:Name='cbSelected'
Content='Selected'
Margin='10,0,0,0'
IsChecked='{Binding IsSelected}' />
</StackPanel>
</DataTemplate>
</Application.Resources>
</Application>
我项目的结构
我在SQL Server中的表:
CREATE TABLE [dbo].[Fruits]
(
[ID] [uniqueidentifier] NOT NULL,
[FruitName] [nvarchar](50) NULL,
[FruitColor] [nvarchar](50) NULL,
[IsSelected] [nvarchar](1) NULL,
CONSTRAINT [PK_Fruit]
PRIMARY KEY CLUSTERED ([ID] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
请告知为什么消息说它不存在时没有主键