我想使用 ASP.NET Boilerplate 一次连接到两个数据库。我按照这个例子:https : //github.com/aspnetboilerplate/aspnetboilerplate-samples/tree/master/MultipleDbContextEfCoreDemo
问题是只有第一个上下文才会有所有的 Abp 表。第二个上下文是现有数据库,其中没有任何 Abp 表。
当我启动 Web 应用程序时,我得到以下信息:
System.Data.SqlClient.SqlException: 'Invalid object name 'AbpLanguages'.'
Run Code Online (Sandbox Code Playgroud)
很明显,它正在第二个上下文中寻找 Abp* 表,但它们不存在(而且它们不应该存在)。那么,拥有多个上下文的正确方法是什么,这样它就不会在第二个上下文中查找 Abp* 表?
我通过修改从模板生成的干净的 ASP.NET Boilerplate 项目创建了一个示例应用程序。
我已经使用模板生成的项目进行了测试,该项目仅适用于 API,并且可以完美运行。但是当 API 和前端在生成项目时结合使用时,我会遇到这些问题,在其他上下文中查找 Abp* 表。
Dropbox:https
: //www.dropbox.com/s/19gj8ms0jwz500k/4.0.1.zip ? dl =0 Github:https : //github.com/FrikkinLazer/MultipleContext.git
c# dbcontext entity-framework-core asp.net-core aspnetboilerplate
在我的手机上安装后(也发生在模拟器上),Widget只有1x1个单元格.
我已经尝试完全卸载应用程序,然后再次安装它,但是当我创建它的实例时,小部件仍然只有1x1单元格大.
有任何想法吗?
这是我的提供者信息XML文件(callernator_widget_provider_info.xml):
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android">
android:minWidth="294dp"
android:minHeight="294dp"
android:updatePeriodMillis="86400000"
android:initialLayout="@layout/widgetmain"
</appwidget-provider>
Run Code Online (Sandbox Code Playgroud)
这是布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:text="Bertus van Zyl" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:text="Button" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.callernator"
android:versionCode="1"
android:versionName="1.0">
<uses-permission
android:name="android.permission.READ_CONTACTS">
</uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name=".CallernatorWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/callernator_widget_provider_info" />
</receiver>
<activity android:name=".CallernatorActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" …Run Code Online (Sandbox Code Playgroud)